-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathstore.js
38 lines (36 loc) · 1.01 KB
/
store.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* THIS IS THE DEFAULT STORE...
*/
import Vue from "vue";
import Vuex from "vuex";
// import axios from "axios";
import { createStore } from "vuex-extensions";
// import createPersistedState from 'vuex-persistedstate';
Vue.use(Vuex);
// load modules
import modules from "./modules";
export default createStore(Vuex.Store, {
modules,
// plugins: [createPersistedState()],
mixins: {
actions: {
async ajax({ state, commit }, url, cbObj, method = "get") {
try {
let res = await axios[method](url);
commit("changeState", {
cbObj: res.data
});
} catch (error) {
console.log(error);
}
}
},
mutations: {
changeState: function(state, changed) {
Object.entries(changed).forEach(([name, value]) => {
state[name] = value;
});
}
}
}
});