{"action":"created","issue":{"url":"https://api.github.com/repos/hapijs/discuss/issues/103","labels_url":"https://api.github.com/repos/hapijs/discuss/issues/103/labels{/name}","comments_url":"https://api.github.com/repos/hapijs/discuss/issues/103/comments","events_url":"https://api.github.com/repos/hapijs/discuss/issues/103/events","html_url":"https://github.com/hapijs/discuss/issues/103","id":70305924,"number":103,"title":"How can i modify my response?","user":{"login":"chanakyap","id":4658149,"avatar_url":"https://avatars.githubusercontent.com/u/4658149?v=3","gravatar_id":"","url":"https://api.github.com/users/chanakyap","html_url":"https://github.com/chanakyap","followers_url":"https://api.github.com/users/chanakyap/followers","following_url":"https://api.github.com/users/chanakyap/following{/other_user}","gists_url":"https://api.github.com/users/chanakyap/gists{/gist_id}","starred_url":"https://api.github.com/users/chanakyap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chanakyap/subscriptions","organizations_url":"https://api.github.com/users/chanakyap/orgs","repos_url":"https://api.github.com/users/chanakyap/repos","events_url":"https://api.github.com/users/chanakyap/events{/privacy}","received_events_url":"https://api.github.com/users/chanakyap/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-23T04:38:18Z","updated_at":"2015-04-23T07:26:46Z","closed_at":null,"body":"I am trying to add api version number to all my responses from the API. \r\nAll responses from my API are JavaScript objects like,\r\n reply({user:{name: 'foo',email: 'bar@foo.com'}});\r\n\r\nSo i am doing this to get my desired result.\r\n\r\n```javascript\r\nserver.ext('onPreResponse', function (request, reply) {\r\n    var response = request.response;\r\n      Wreck.read(response, {json: true}, function (err, body) {\r\n        body.version = 'api_version #0.1#';\r\n        body.copyright = 'copyright';\r\n        body.timestamp = Date.now();\r\n        reply(body);\r\n      });\r\n  });\r\n```\r\nBut wreck throws an error , because request.response.variety is 'plain' and not 'stream'.\r\nI want the final response/result to be\r\n {\r\n    user:{name: 'foo',email: 'bar@foo.com'},\r\n    version: 'api_version #0.1#',\r\n    timestamp: //current date\r\n }\r\n\r\nHow should i go about this?\r\n\r\nhttps://github.com/hapijs/wreck/issues/80"},"comment":{"url":"https://api.github.com/repos/hapijs/discuss/issues/comments/95475151","html_url":"https://github.com/hapijs/discuss/issues/103#issuecomment-95475151","issue_url":"https://api.github.com/repos/hapijs/discuss/issues/103","id":95475151,"user":{"login":"chanakyap","id":4658149,"avatar_url":"https://avatars.githubusercontent.com/u/4658149?v=3","gravatar_id":"","url":"https://api.github.com/users/chanakyap","html_url":"https://github.com/chanakyap","followers_url":"https://api.github.com/users/chanakyap/followers","following_url":"https://api.github.com/users/chanakyap/following{/other_user}","gists_url":"https://api.github.com/users/chanakyap/gists{/gist_id}","starred_url":"https://api.github.com/users/chanakyap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chanakyap/subscriptions","organizations_url":"https://api.github.com/users/chanakyap/orgs","repos_url":"https://api.github.com/users/chanakyap/repos","events_url":"https://api.github.com/users/chanakyap/events{/privacy}","received_events_url":"https://api.github.com/users/chanakyap/received_events","type":"User","site_admin":false},"created_at":"2015-04-23T07:26:46Z","updated_at":"2015-04-23T07:26:46Z","body":"@AdriVanHoudt Thanks man, i have tried this(since your code did not work),\r\nserver.ext('onPreResponse', function (request, reply) {\r\n    var source = request.response.source;\r\n     source.version = 'api_version #0.1#';\r\n     source.copyright = 'copyright';\r\n     source.timestamp = Date.now();\r\n     return reply.continue();\r\n  });\r\n\r\nand it works. The sad thing is, i had to do lot of trail and errors to get here, is it the documentation or just me ? "}}