fetch promise is resolved even on 4xx and 5xx response codes


I have been assuming all this time that fetch promise must be rejected on 4xx and 5xx response codes. Because this has been the behaviour with jQuery.ajax and axios. But fetch doesn't follow that. A fetch promise is only considered rejected when the client is not able to establish a connection to the server e.g. Host down, No internet connection, Server refused the connection etc

More details on this StackOverflow Post

... Loading comments