axios: Broken interceptor error response
Hello, I have upgraded axios from 0.12 to 0.16.2 and it looks like that interceptors response is quite diffrent:
Interceptor example code:
axios.interceptors.response.use(response => Promise.resolve(response), (error) => {
console.log(error);
return Promise.reject(error);
});
On version 0.12 it returns nice object:

However on version 0.16.2 it seems to return error stack for the request:

Making interceptors in axios quite useless in my project (I am using it to refresh access token for logged user).
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 4
- Comments: 15
Using v0.17.1
Also the same here, error.response is undefined.
Object.keys(error).forEach(key => console.log(key)) returns config, request, response
but error.response returns undefined. So it’s there but undefined.
Seems to be broken for me as well. Only keys are config and request. Can’t get the status code.
0.18error.response returns undefined. error.status returns undefined.I use the 0.17.1 log only having the config and request but the same version in my workmate’s project having the response ! so sad!
Try
error.dataorerror.statusto get all data listed above.It means the
errorrejected by promise is anerror objectnot aplain object.You can traversal this error object by using
Object.keys(error).forEach(key => ...)