This repository has been archived on 2024-12-15. You can view files and clone it, but cannot push or open issues or pull requests.
seepur/resources/scripts/applications/admin/state.vuex.ts

29 lines
557 B
TypeScript
Raw Normal View History

2020-03-17 22:16:34 +00:00
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;