axios-module icon indicating copy to clipboard operation
axios-module copied to clipboard

responseInterceptor does not get called on error

Open uptownhr opened this issue 9 years ago • 4 comments

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

This question is available on Nuxt.js community (#c27)

uptownhr avatar Sep 19 '17 22:09 uptownhr

Yeah, I got the same problem here.

pschmidt88 avatar Oct 08 '17 16:10 pschmidt88

I'm already set disableDefaultErrorHandler to true, but still nothing happens..

ahDDD avatar Jan 12 '18 09:01 ahDDD

+1

CyberNika avatar Jan 27 '18 14:01 CyberNika

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 :)

pi0 avatar Jan 28 '18 16:01 pi0