Yes, there are a lot of post like this, but i can't figure out whats happening (look for a lot of post here and in Google).
I made my interceptor like this, but I'm getting a message "This is undefined".
axios.interceptors.response.use(undefined, function(err) {
return new Promise(function(resolve, reject) {
if (err.request.status === 401 && err.config && !err.config.__isRetryRequest) {
console.log('Disconnected. Session expires')
this.$store.dispatch('logout')
this.$router.push({ name: "login" });
}
throw err;
});
First I had "() => {}" and I have changed to "function() {}", but same error.
How can I do to clear my code?