matthew-andrews / isomorphic-fetch

Isomorphic WHATWG Fetch API, for Node & Browserify
MIT License
6.95k stars 289 forks source link

get 404 response body as response? #120

Open eduardoinnorway opened 7 years ago

eduardoinnorway commented 7 years ago

First time using isomorphic-fetch, really like it but I have an issue,

I cant get the response body from a GET when it is 404.

I try to get /api/foo/:bar

And in the REST API I am calling I get a JSON 404 answer I would like to work with, but fetch just ignores that response on 404, the response is empty and I get error on the code on "return fetch", that is "Failed to load resource: the server responded with a status of 404 (Not Found)".

Anyone else had this issue?

phkavitha commented 7 years ago

I too have this issue.. I want to access the response body when the response code is 404.

lmj0011 commented 7 years ago

you have to define a handler to detect the 404 and other error codes

see: https://github.com/github/fetch#caveats https://github.com/github/fetch#handling-http-error-statuses