maybe it's a simple question.
I want to ask how to interrupt axios request in nuxt/vue.
this is my scenarios:
what i expect
I am using axios as a plugin, this is my config
// plugins/axios.js
app.$axios.setHeader('accept-encoding', null)
app.$axios.setHeader('Content-Type', 'application/json')
app.$axios.setHeader('Authorization', token)
app.$axios.onError(async error => {
if (typeof error.response !== "undefined") {
if (error.response.status === 401) {
jscookie.set("fallback_url", window.$nuxt.$route.path)
jscookie.remove('token');
window.location.href = '/logout'
return
}
return Promise.reject(error);
} else {
throw error
}
})
Thank you