Skip to content

Instantly share code, notes, and snippets.

@vouill
Created December 4, 2017 11:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vouill/4038dcfe7dc304262548d50f99e71bdf to your computer and use it in GitHub Desktop.
Save vouill/4038dcfe7dc304262548d50f99e71bdf to your computer and use it in GitHub Desktop.
app.vue mehtod handling unauthorize
created: function () {
axios.interceptors.response.use(undefined, function (err) {
return new Promise(function (resolve, reject) {
if (err.status === 401 && err.config && !err.config.__isRetryRequest) {
// if you ever get an unauthorized, logout the user
this.$store.dispatch(AUTH_LOGOUT)
// you can also redirect to /login if needed !
}
throw err;
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment