[b]"Does Fetch API throw errors when a request fails?"[/b] Alternatively: [b]"How does Fetch API throw errors, and

18 Replies, 664 Views

Fetch is weird like that. Network errors? Rejected promise. HTTP errors? "Here’s a response, good luck!"

I handle it by creating a custom fetch wrapper that throws on non-2xx. Also, `ky` is a solid alternative if you want something fetch-like but with sane defaults.

Messages In This Thread



Users browsing this thread: 1 Guest(s)