Created
October 8, 2018 19:12
-
-
Save gnumarcelo/98b9016679ffe9136b56eea61b9e520f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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