Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//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