Hej,
Mam pewien problem ponieważ nie wiem jak się odwołać do routingu. Mam kod który wylogowuje użytkownika ale niestety nie wiem jak dodać także zmianę routing z aktualnego na login
const actions = {
[VERIFY_AUTH](context) {
if (JwtService.getToken()) {
ApiService.setHeader();
ApiService.get("/sanctum/verify")
.then(({ data }) => {
context.commit(SET_AUTH, data);
})
.catch(() => {
context.commit(PURGE_AUTH);
});
} else {
context.commit(PURGE_AUTH);
}
},
};
const mutations = {
[PURGE_AUTH](state) {
state.isAuthenticated = false;
state.user = {};
state.errors = {};
this.$router.push({ name: "login" });
JwtService.destroyToken();
}
};
Nie wiem w którym miejscu dodać
this.$router.push({ name: "login" });
Próbowałem dodać w catch pod context.commit purge ale mam następujący błąd:
Uncaught (in promise) TypeError: this.$router is undefined
Próbowałem dodać .bind(this) ale nie pomogło.