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
Status code is missing in toJSON method of axios error #2947
Comments
byrne-greg
pushed a commit
to byrne-greg/axios
that referenced
this issue
May 8, 2020
byrne-greg
added a commit
to byrne-greg/axios
that referenced
this issue
May 8, 2020
jasonsaayman
added a commit
that referenced
this issue
Sep 5, 2021
* Adding HTTP status code to error.toJSON (#2947) * Adding Error display div to internal server client.html Co-authored-by: Jay <jasonsaayman@gmail.com>
Fixed with #2956 2956 |
mbargiel
pushed a commit
to mbargiel/axios
that referenced
this issue
Jan 27, 2022
* Adding HTTP status code to error.toJSON (axios#2947) * Adding Error display div to internal server client.html Co-authored-by: Jay <jasonsaayman@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
When calling the
toJSON
method on an axios error (inside acatch
clause), the returned object does not include the error status code.toJSON
is useful for extracting the main error details, and the status code should be part of it as well.To Reproduce
Run the below code. No status code field in the output.
The only place status code appears in the
toJSON
object is in the message: "Request failed with status code 404"There's a
status
field (which is alwaysundefined
btw), but according to the code, it is a connection error string (for example, 'ECONNABORTED'), not the response numeric status code.Expected behavior
A numeric
statusCode
field should be part of thetoJSON
returned object.Environment:
The text was updated successfully, but these errors were encountered: