axios-module
axios-module copied to clipboard
responseInterceptor does not get called on error
One good place to put some global error handlers is on the responseInterceptor, but looks like it is not being called when the request errors.
responseInterceptor: (response, { store, redirect }) => {
console.log('response', response)
if (response.status.code == 401) {
store.dispatch('logout')
redirect('/login')
}
return response
}
using version: 4.3.0
Yeah, I got the same problem here.
I'm already set disableDefaultErrorHandler to true, but still nothing happens..
+1
With 5.x version, we have deprecated responseInterceptor. Instead, there is a better solution to use nuxt plugins.
Please see Extending Axios section and don't forget to migration guide :)