Skip to content

Instantly share code, notes, and snippets.

@akhbar
Created September 20, 2018 08:17
Show Gist options
  • Save akhbar/5637abb828482c5194c08e9640492c70 to your computer and use it in GitHub Desktop.
Save akhbar/5637abb828482c5194c08e9640492c70 to your computer and use it in GitHub Desktop.
new store
import Vue from 'vue';
import Vuex from 'vuex';
import createPersistedState from "vuex-persistedstate";
import * as Cookies from "js-cookie";
Vue.use(Vuex);
export const store = new Vuex.Store({
state: {
data:{}
},
getters: {
data:state => state.data
},
actions: {
setData(context, payload) {
context.commit('SET_DATA', payload);
},
clearData(context) {
context.commit('CLEAR_DATA')
}
},
mutations: {
SET_DATA: (state, payload) => {
state.data.secureToken = payload;
},
CLEAR_DATA: (state) => {
state.data = {}
}
},
plugins: [
createPersistedState()
]
})
//export default store
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment