Skip to content

Instantly share code, notes, and snippets.

@gnumarcelo
Created October 8, 2018 19:12
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gnumarcelo/98b9016679ffe9136b56eea61b9e520f to your computer and use it in GitHub Desktop.
Save gnumarcelo/98b9016679ffe9136b56eea61b9e520f to your computer and use it in GitHub Desktop.
//plugins/axios.js
export default function ({ $axios, app }) {
$axios.onError(error => {
const code = parseInt(error.response && error.response.status)
if ([401, 403].includes(code)) {
app.$auth.logout();
}
return Promise.reject(error);
})
}
//nuxt.config.js
plugins: [
'~/plugins/axios'
],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment