Cancel promise in axios interceptor to ensure redirection

This commit is contained in:
Bubka 2020-01-27 13:55:14 +01:00
parent f2dbf3f1e2
commit 52ac639940

5
resources/js/api.js vendored
View File

@ -43,10 +43,13 @@ Vue.axios.interceptors.response.use(response => response, error => {
// Otherwise we push to the error views
if ( error.response.status === 404 ) {
router.push({name: '404', params: { err : error.response }})
router.push({name: '404'})
throw new Vue.axios.Cancel('pushed to 404');
}
else {
router.push({ name: 'genericError', params: { err: error.response } })
throw new Vue.axios.Cancel('pushed to generic error');
}