In my Laravel 5.8 / "vue": "^2.6.10"/ "vuex": "^3.1.0" app In resources/js/components/Login.vue file I have method
methods: {
authenticate() {
this.$store.dispatch('login'); // calling action
login(this.$data.form)
.then((res) => {
this.$store.commit("setLoginSuccess", res); // calling mutation
this.$store.dispatch('retrieveHostelBookmarks', res.user.id);
this.$store.dispatch('retrievePersonalOptions', res.user.id);
this.$router.push({path: '/personal'}); // For debugging!
})
.catch((error) => {
console.log("=== error::")
console.log(error)
this.$store.commit("setLoginFailed", {error}); // calling mutation
});
}
and in resources/js/helpers/authFuncs.js I have definition :
export function login(credentials) {
return new Promise((res, rej) => {
axios.post('/api/auth/login', credentials)
.then((response) => {
setAuthorizationToken(response.data.access_token);
res(response.data);
})
.catch((err) =>{
console.error(err)
rej("Wrong email or password");
})
})
}
and the problem is that on invalid credentials in the console I see promise warning in the end of output :
VM836:1 POST http://127.0.0.1:8084/api/auth/login 401 (Unauthorized)
(anonymous) @ VM836:1
dispatchXhrRequest @ app.js?dt=1571914585:311
xhrAdapter @ app.js?dt=1571914585:150
dispatchRequest @ app.js?dt=1571914585:758
Promise.then (async)
request @ app.js?dt=1571914585:560
Axios.<computed> @ app.js?dt=1571914585:585
...
app.js?dt=1571914585:10042 === error::
app.js?dt=1571914585:10043 Wrong email or password
app.js?dt=1571914585:131483 Uncaught (in promise) NavigationDuplicated {_name: "NavigationDuplicated", name: "NavigationDuplicated", message: "Navigating to current location ("/login") is not allowed", stack: "Error↵ at new NavigationDuplicated (http://127.…/127.0.0.1:8084/js/app.js?dt=1571914585:148080:12"}
Why this warning and how to fix it?