title: router in vue is undefined
body: <p>I have added a axios interceptor in my App.vue to catch all status 401, so I can logout users. I am trying to redirect to the login page. I keep getting "Cannot read property '$router' of undefined" not sure what the problem is. Any help? Also is there a better way to handle axios http status errors globally. Instead of checking if status is 400,401 etc on each component that makes a http request.</p>
  
  <pre><code>created: function () {
    axios.interceptors.response.use(undefined, function (err) {
      return new Promise(function (resolve, reject) {
  
        if (err.response.status=== 401 ) {
  
          this.$router.push({ name: 'loginview' })
  
      }
        throw err;
     });
    });
  }
  </code></pre>