Static GitHub Issues

[1074] How to get vue-route instance in plugins/axios

prev: Attempting to integrate Jest with Nuxt.js
next: Is there any way to access nuxt context(error handler) after the page rendered

i hava a interceptors in plugins/axios,and i need get the vue-route instance to jump to login page when the response.data.code === 401

let $http = axios.create(options)

// interceptors response
$http.interceptors.response.use(response => {
  if (response.data.code === 401) {
   //jump to login
  }
  return response;
}, function (error) {
  return Promise.reject(error);
});

export default $http
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c934">#c934</a>)</em></sub></div>