src/store/modules/authStore.js
/**
     * Initialize from cache (localstorage)
     */
Initialize from cache (localstorage)
Initialize from cache ( localstorage )
init(context) {
      try {
        let user;
        if (localStorage.getItem(variables.auth.userdetais) !== 'undefined') {
          user = JSON.parse(localStorage.getItem(variables.auth.userdetais));
        }
        let token;
        if (localStorage.getItem(variables.auth.appToken) !== 'undefined') {
          token = JSON.parse(localStorage.getItem(variables.auth.appToken));
        }
        context.commit('setUser', user);
        context.commit('setToken', token);
      } catch (err) {
        console.error(err);
      }
    }
init ( context ) { try { let user ; if ( localStorage . getItem ( variables . auth . userdetais ) !== 'undefined' ) { user = JSON . parse ( localStorage . getItem ( variables . auth . userdetais ) ) ; } let token ; if ( localStorage . getItem ( variables . auth . appToken ) !== 'undefined' ) { token = JSON . parse ( localStorage . getItem ( variables . auth . appToken ) ) ; } context . commit ( 'setUser' , user ) ; context . commit ( 'setToken' , token ) ; } catch ( err ) { console . error ( err ) ; } }
Initialize from cache (localstorage)
Initialize from cache ( localstorage )