Why isn't error set for 4XX/5XX http status codes? #634
Unanswered
aloukissas
asked this question in
General
Replies: 1 comment 4 replies
-
This is not a SWR thing but a Fetch API issue, the API doesn’t throw an error when an HTTP 4xx/5xx error is thrown, so you need to do it, remember SWR can work with anything as a fetcher function. What I usually do is to create a generic wrapper of fetch to check the status and throw an error. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This is still counter-intuitive - I always have to write this extra code in my
fetcher
function to check e.g.if (res.ok)
.How do people use this? Am I missing something?
Beta Was this translation helpful? Give feedback.
All reactions