0

I am using store variable and updating it but when I refresh the page, the data gets empty

I have defined a variable and tried to use it as "this.state.userInfo"

export default new Vuex.Store({
    state: {
        status: '',
        token: localStorage.getItem('token') || '',
        userInfo: {}
    },
    actions: {
        login () {
            this.state.userInfo = "John"
        },
        autoLogin () {
            const userInfo = this.state.userInfo
        }
  }
})

this.state.userInfo should be updated but it is reflecting me an empty value when I refresh the page.

Riddhi
  • 2,174
  • 1
  • 9
  • 17
Mandar Chavan
  • 31
  • 1
  • 1

0 Answers0