You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is super handy when logging errors as AxiosError gets stringified in JSON loggers (e.g. bunyan) to a very sensible subset of all that the error and the request/response include.
Example JSON.stringify(axiosError):
{
"message": "Request failed with status code 404",
"name": "Error",
"stack": "Error: Request failed with status code 404\n at createError…",
"config": {
"url": "https://www.google.com/foo",
"headers": {
"Accept": "application/json, text/plain, */*",
"User-Agent": "axios/0.19.2"
},
"transformRequest": [null],
"transformResponse": [null],
"timeout": 0,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1,
"method": "get"
}
}
Example JSON.stringify(gotError):
{ "name": "HTTPError" }
Checklist
I have read the documentation and made sure this feature doesn't already exist.
The text was updated successfully, but these errors were encountered:
What problem are you trying to solve?
Easier serialization of errors for logging purposes.
Describe the feature
axios
recently implementedtoJSON()
onAxiosError
(axios/axios#1625).This is super handy when logging errors as
AxiosError
gets stringified in JSON loggers (e.g.bunyan
) to a very sensible subset of all that the error and the request/response include.Example
JSON.stringify(axiosError)
:Example
JSON.stringify(gotError)
:Checklist
The text was updated successfully, but these errors were encountered: