forked from sagi/seepur
29 lines
557 B
TypeScript
29 lines
557 B
TypeScript
|
import Vue from 'vue';
|
||
|
import Vuex, { Store } from "vuex";
|
||
|
import Services from '../services';
|
||
|
Vue.use(Vuex);
|
||
|
const store = new Store({
|
||
|
strict: true,
|
||
|
state: {
|
||
|
users: null,
|
||
|
},
|
||
|
getters: {
|
||
|
users(state) {
|
||
|
return state.users;
|
||
|
}
|
||
|
},
|
||
|
mutations: {
|
||
|
setUsers: (state, users) => {
|
||
|
state.users = users;
|
||
|
}
|
||
|
},
|
||
|
actions: {
|
||
|
getUsers: async (ctx) => {
|
||
|
console.log('store get users');
|
||
|
const users = await Services.ApiService.getAllUsers();
|
||
|
ctx.commit('setUsers', users);
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
export default store;
|