Rejection handling doesn't seem to be working
Closed this issue · 5 comments
Hi,
I have a component that makes a GET
request to an API endpoint. When this API call results in a non-success status code (i.e. 400), I would have expected the fetch state to be rejected
.
Right now, this is not the case. When this situation occurs, the state is set to fulfilled
.
I suspect it has something to do with the following line:
https://github.com/hirviid/react-redux-fetch/blob/master/src/utils/handleResponse.js#L4
Since an error response has no content-length
, it ends up in this if-branch, but that doesn't actually reject the promise.
Hm yeah indeed. This was a literal copy-paste from react-refetch. But I guess we can do a Promise.reject...
if the status is not in the 200 - 300 range.
I don't think this will cause problems for anyone. As you say, a 400 should be rejected.
Yes, that sounds reasonable 👍
Any idea when you'll publish the new version? :)
Now! :)
Available in react-redux-fetch@0.8.0
Haha awesome, thanks! :)