July 2018
Intermediate to advanced
354 pages
8h 51m
English
As I mentioned earlier, fetch does not throw an exception or return an error if the response status is not 200. Instead, as long as fetch receives a response, it does not fail. It is still up to you to interrogate the response status to determine how you want to process the response.
The ok property is true if the status code is 200-299, and false otherwise. It can be a quick way to verify a request's success. Just be careful, as sometimes you can receive a 0 status code for cached, cross-origin responses.
In practice, many requests can have a range of successful status codes. HTTP status codes are grouped by 100s. 200-299 indicates a successful response, while 300-399 indicates a redirect and is accompanied ...
Read now
Unlock full access