Open RaphaelMcledger opened 3 years ago
Relevant code or config
import Vue from "vue"; import Vuex from "vuex"; import createPersistedState from "vuex-persistedstate"; import Cookies from "js-cookie"; import module1 from "./module1"; import module2 from "./module2"; Vue.use(Vuex); let secure = true; const storage = (e) => { return { getItem: () => { Cookies.get(e); console.log(Cookies.get(e)); }, setItem: (key, value) => { Cookies.set(e, JSON.stringify(JSON.parse(value)[e]), { expires: 3, secure: secure }); }, removeItem: () => Cookies.remove(e) }; }; const modules = { module1, module2 }; const plugins = []; Object.keys(modules).forEach((e) => { plugins.push( createPersistedState({ key: e, storage: storage(e) }) ); }); export default new Vuex.Store({ state: {}, mutations: {}, actions: {}, plugins: plugins, modules: modules });
What you did: I want to get one cookie by modules What happened: On refresh cookies dispear
Reproduction sandbox: https://codesandbox.io/s/lively-forest-5pcry
Problem description: When i console.log Cookies.get() on get in storage i got undefined when Suggested solution:
Relevant code or config
What you did: I want to get one cookie by modules What happened: On refresh cookies dispear
Reproduction sandbox: https://codesandbox.io/s/lively-forest-5pcry
Problem description: When i console.log Cookies.get() on get in storage i got undefined when Suggested solution: