0๐
โ
So I solved my problem by using axios interceptors. I check if the error status in 401 (Unauthorised) and push router to the login page.
axiosInstance.interceptors.response.use(null, (error) => {
if (error.response.status === 401) {
config.token = null;
router.push({ name: 'login' });
}
if (error.response.status === 404) {
router.push({ name: 'error' });
}
return Promise.reject(error);
});
๐คOlga B
Source:stackexchange.com