I am using the following guard const to prevent user from entering pages while they don't have a token saved on cookies. However if i try it enough time the user is able to enter the page but the components don't load, is is just a blank page
What else should i add to my router file to prevent this kind of thing from happening?
Here is my guard constant:
const guard = function(to, from, next) {
const token = Cookies.get('token')
if(typeof token === 'undefined' || token === null ){
this.$store.dispatch('logout')
window.location.href = "/";
} else {
next();
}
};