Kinda wild that fetch doesn’t throw for HTTP errors, right? Like, a 404 *is* a failure, so why not reject?
I ended up writing a tiny utility that wraps fetch and auto-throws for non-2xx responses. Also adds timeouts, which fetch doesn’t do natively.
If you don’t wanna DIY, check out `wretch`—it’s a fetch wrapper with better error handling.
I ended up writing a tiny utility that wraps fetch and auto-throws for non-2xx responses. Also adds timeouts, which fetch doesn’t do natively.
If you don’t wanna DIY, check out `wretch`—it’s a fetch wrapper with better error handling.
