Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vuex store losing data on PAGE REGRESH

I am building authentication system in laravel and vuejs, I am building using JWT and storing token in lacalstorage. I am able to store user data in vuex store and yes i can see under vuex area in devtool. The problem is when i am refreshing page i am losing it . I wanna persist user's information, It should not get deleted on a page refresh . How can i achieve that

import Vue from 'vue'
import Vuex from 'vuex'

import userStore from './components/user/userStore'

Vue.use(Vuex)

const debug = process.env.NODE_ENV !== 'production'


export default new Vuex.Store({
    modules : {
        userStore
    },
    strict : debug
})
like image 233
waq Avatar asked Nov 08 '22 15:11

waq


1 Answers

You can try using this plugin

https://github.com/championswimmer/vuex-persist

A Typescript-ready Vuex plugin that enables you to save the state of your app to a persisted storage like Cookies or localStorage.

like image 150
Souljacker Avatar answered Nov 15 '22 12:11

Souljacker