axios: 0.13 Error handling does not handle exceptions
After upgrade from 0.12 to 0.13, catch
method does not catch an error, an exception occurs and the whole process aborts.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 10
- Comments: 20 (5 by maintainers)
@SOSANA There is no ‘extra response object’ in your example.
When an
Error
is thrown, theresponse
variable will contain theError
. I would suggest to rename that variable toerror
:If a response has been received from the server, the
error.response
will contain a response object. Thedata
property of the response object will contain the response payload. (See this for details about the response schema.)Hope this helps!
Same here. There is some issues with the error object. Previously, we were able to retrieve the error object. We are facing issues now. I am rolling back to the previous version.
Below is the error message I get in the console:
In the previous version, I used to get the proper error object with status code.
Had this issue
Got it fixed by
@nickuraltsev I followed the examples using
.catch(err)
but theerr
is just an exception. Doesn’t contain the returning object like the example shows.I worked around this by nesting my response call:
instead of
The original error was a type error because response.data didn’t exist.
@mzabriskie
I reverted to 0.12.0 and now I get a proper error object.
nickuraltsev’s answer solve this problem,a hidden
error.response
.@alexi21 It’s not the same. You are talking about a documented change mentioned here. In my case the
catch
method is not even called.