Closed isaachinman closed 1 year ago
https://github.com/hg-pyun/axios-logger#error
If you want to logging error, pass logging function second argument.
Thanks @hg-pyun. Not sure if you understood the question.
Regardless, if anyone comes across this issue in the future, here's how it can be done:
instance.interceptors.response.use(
res => res,
error => errorLogger({
...error,
response: {
...error.response,
data: {
...error.response.data,
_request: error.config.data,
},
},
})
)
We are using
axios-logger
just for error logging in our API, eg:This is working great, however when we receive 4xx responses from some third parties, relevant details are not passed in the error response. The third party might send error/validation content, but not actually reference the entities involved.
Because of this, we want to be able to also log the request body when a 4xx/5xx error is returned.
I haven't been able to work out how this is possible. Any ideas?