Closed nirokun closed 4 years ago
I'm seeing the same thing...
Hey! I managed to fix this in my code. The problem wasn't the localStorage.js, the problem was when the data is charged. With the computed method in the tutorial i was able to use my data stored in localStorage.js. That's lead me to another question. When the data is avalible? Before created or while being created, or before mounted or while being mounted?
This is my localStorage.js ``# store/localStorage.js export const state = () => ({ logged: false, token: '', user: {} })
export const mutations = { loginAction (state, token) { console.log('login') state.user = token state.token = state.user.jti state.logged = true this.$router.push('/') console.log(state) },
logout (state) { console.log('logout') state.token = '' state.user = '' this.$router.push('/') } }
` and with this commnad
this.$store.commit('localStorage/loginAction', response.data)` i change the data. When ever i refresh the page the data reset to initial value.