-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to deal with errors? Not presenting error information. #164
Comments
You will find all this information in the
|
Strange, it's not giving me an object, it's giving me this instead:
Going to try and reproduce it in codesandbox, I'll update this comment afterwards. |
okay sure. that object though is what's returned by axios, see Line 129 in 8706e4c
|
I coudn't reproduce my problem, but I noticed that it's something that is documented in axios. At least I know where the problem lies. Basically the error occurred on the request, so
|
Correct, though unusual, HTTP errors may occur on the request rather than in the response (i.e. there's no network connectivity so the request cannot even leave the local network). In those cases, you will never have a response and in Axios that's communicated by an undefined response on the error object. |
@simoneb I think this is more like react issue, but anyway. I had almost the same problem -- I request a wrong URL, which does not exist, then axios literally died and my NextJS server also died. logs:
I don't think this is normal behavior. Axios dosen't return error, just die with react. |
This is a bug in your code. Neither axios or react simply "die". |
@simoneb Thank you for reply. It was actually ssr issue. when I set option I think nextJS or some of my unconscious setup make axios do a job at server-side. |
Axios has an
error.response
object that mirrors the information present when the server returns a normal response:I would like to have access to this information, but when
const [{ data, loading, error, response }, fetch] = useAxios(...)
returns an error from the server, thedata
andresponse
come with the previously correct response values (undefined if it was the first request made).Shouldn't it update the
data
, or at least theresponse
with the axios'error.reponse
value? Or at least construct the useAxios()'serror
according to that value? Or am I missing the point completely and useAxios() is meant to be used differently when handling errors?Right now, to know the status of the error, I have to extract the number part from the string associated with useAxios()'s
error
value:Error: Request failed with status code 404
The text was updated successfully, but these errors were encountered: