Explorar o código

Cancel promise in axios interceptor to ensure redirection

Bubka %!s(int64=5) %!d(string=hai) anos
pai
achega
52ac639940
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      resources/js/api.js

+ 4 - 1
resources/js/api.js

@@ -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');
     }