{"action":"created","issue":{"url":"https://api.github.com/repos/github/fetch/issues/203","repository_url":"https://api.github.com/repos/github/fetch","labels_url":"https://api.github.com/repos/github/fetch/issues/203/labels{/name}","comments_url":"https://api.github.com/repos/github/fetch/issues/203/comments","events_url":"https://api.github.com/repos/github/fetch/issues/203/events","html_url":"https://github.com/github/fetch/issues/203","id":108125408,"number":203,"title":"How to get the response json on HTTP error 400+ ?","user":{"login":"brijeshb42","id":717550,"avatar_url":"https://avatars3.githubusercontent.com/u/717550?v=3","gravatar_id":"","url":"https://api.github.com/users/brijeshb42","html_url":"https://github.com/brijeshb42","followers_url":"https://api.github.com/users/brijeshb42/followers","following_url":"https://api.github.com/users/brijeshb42/following{/other_user}","gists_url":"https://api.github.com/users/brijeshb42/gists{/gist_id}","starred_url":"https://api.github.com/users/brijeshb42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brijeshb42/subscriptions","organizations_url":"https://api.github.com/users/brijeshb42/orgs","repos_url":"https://api.github.com/users/brijeshb42/repos","events_url":"https://api.github.com/users/brijeshb42/events{/privacy}","received_events_url":"https://api.github.com/users/brijeshb42/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2015-09-24T13:03:20Z","updated_at":"2017-05-24T16:35:43Z","closed_at":"2015-09-24T16:33:45Z","body":"Suppose I create a request to `http://example.com/404`, and the response is **404** status code with a json response like this:\n\n``` json\n{\n  \"type\": \"error\",\n  \"message\": \"What you were looking for isn't here.\"\n}\n```\n\nHow can I get the above json using **fetch**?\n"},"comment":{"url":"https://api.github.com/repos/github/fetch/issues/comments/303780091","html_url":"https://github.com/github/fetch/issues/203#issuecomment-303780091","issue_url":"https://api.github.com/repos/github/fetch/issues/203","id":303780091,"user":{"login":"developer239","id":14946081,"avatar_url":"https://avatars2.githubusercontent.com/u/14946081?v=3","gravatar_id":"","url":"https://api.github.com/users/developer239","html_url":"https://github.com/developer239","followers_url":"https://api.github.com/users/developer239/followers","following_url":"https://api.github.com/users/developer239/following{/other_user}","gists_url":"https://api.github.com/users/developer239/gists{/gist_id}","starred_url":"https://api.github.com/users/developer239/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/developer239/subscriptions","organizations_url":"https://api.github.com/users/developer239/orgs","repos_url":"https://api.github.com/users/developer239/repos","events_url":"https://api.github.com/users/developer239/events{/privacy}","received_events_url":"https://api.github.com/users/developer239/received_events","type":"User","site_admin":false},"created_at":"2017-05-24T16:35:43Z","updated_at":"2017-05-24T16:35:43Z","body":"I ended up doing something like this. Probably not best but definitelly one of the shortes solutions. I just did not want to look at all those nested promises.\r\n\r\n```\r\nconst parseFetchResponse = response => response.json().then(text => ({\r\n  json: text,\r\n  meta: response,\r\n}))\r\n\r\nreturn fetch(...your stuff...)\r\n  .then(parseFetchResponse)\r\n  .then(({ json, meta }) => {\r\n    console.log('(response, meta)')\r\n    console.log(json)\r\n    console.log(meta)\r\n})\r\n```"}}
{"actor":{"display_login":"developer239"}}