Closed elenate closed 7 years ago
I would say that if body is empty and response status code is 2xx then promise should not be rejected. Is the response code 204 when body is empty or is it 200?
Is the response code 204 when body is empty or is it 200?
no, response code is 403
Ok, then it makes sense.
the only reason why promise is rejected its because for whatever reason fetch cant handle response and explodes, and rejecting the promise makes sense because its not normal flow
Sometimes it can happen that API will respond with empty body, and you will not get response and status code, which is bad, but you get internal Fetch error, but it also dousnt help and its only source of confusion. So by adding this, catch we can gracefully handle invalid API response