You should also remember that fetch does not consider anything bellow 500 from the response to be an error.
Thus if you're retrying the request because of a timeout, you should specifically check for the status code 408.
All other codes should also probably be handled accordingly. At least there's always been a need to handle specific error codes for me rather than checking
switch(true){caseresponse.ok:{// That's really cool.// But I should really also check the status code as well}default:{// Whatever then}}
You should also remember that
fetchdoes not consider anything bellow500from the response to be an error.Thus if you're retrying the request because of a timeout, you should specifically check for the status code
408.All other codes should also probably be handled accordingly. At least there's always been a need to handle specific error codes for me rather than checking
Yup. Thank you for pointing out that!
In my case, I only want to handle network failure. So I haven't mentioned it.