Я случайно получаю сообщение об ошибке next({ path: 'dfdfd' })
.
Ошибка Uncaught (in promise) undefined
, которая, по моему мнению, не позволяет запустить остальную часть моего сценария.
I перепробовал все варианты из интернета, но все они касаются использования $router.push
not next()
.
next({path: '/profile'}, () => {});
next({path: '/profile'}).catch(()=> {});
try { next({path: '/profile'}) } catch(err){}
Ничего не делать.
Может кто-нибудь сказать мне, как я ловлю эту ошибку ?
С уважением
Редактировать.
Вышеуказанное используется при обработке ошибок запроса ax ios, который вызывается из vue -routers beforeRouteEnter
и beforeRouteUpdate
методы.
/**
* Error Handler
* @param error
* @param next
* @param to
* @param from
*/
errorHandler(error, next, to, from) {
switch(error.response.status) {
case 401:
if(from.path !== '/login') {
next({path: '/login'});
} else {
next();
}
break;
case 498:
for(let i in error.response.data.errors) {
db.commit('setNotifications', []);
db.commit('addErrorNotification', error.response.data.errors[i][0]);
}
if(from.path !== '/profile') {
next({path: '/profile'}); // where the error is thrown
} else {
next();
}
break;
default:
next();
break;
}
db.commit('setPageLoading', false);
}