title: Vue.js and Axios - redirect on 401
body: <p>I'm running <code>Vue.js</code> and <code>axios</code> and are trying to make a generic API object like the following:</p>
  
  <pre><code>import router from './router'
  import auth from './auth'
  const axios = require('axios')
  
  export const API = axios.create({
    baseURL: `https://my-api.com/`,
    headers: {
      Authorization: auth.getToken()
    }
  })
  
  API.interceptors.response.use(null, function (error) {
    if (error.response.status === 401) {
      console.log('Failed to login')
      router.push('/Login')
    }
    return Promise.reject(error)
  })
  </code></pre>
  
  <p>I'm trying to have the users redirected to the <code>Login</code> screen in my single page app, whenever a <code>401</code> error code is received.
  But I'm not getting redirected, and no error occurs in my Developer Tools in Chrome. I do get the <code>console.log</code> with <code>Failed to login</code>.</p>