[Vuejs]-LoggedIn state reverts back to false after Logging in and doesn't allow me to guard route

0👍

You need to store the loggedIn user in local storage:

setLogin: (state) => {
 state.loggedIn = localStorage.setItem('loggedIn', 'true')
 state.loggedIn = true
},

Then your state should look like:

state: {
    loggedIn: localStorage.getItem('loggedIn') || null,
},

Leave a comment