import { ActionTree, GetterTree, MutationTree, ActionContext, Module } from 'vuex' import { ICategory, CategoryService } from 'client/service/Category' interface CategoryState { categoryList: ICategory[] } const state: CategoryState = { categoryList: [] } const getters: GetterTree = {} const actions: ActionTree = { async loadCategoryList({ commit }: ActionContext): Promise { const data: ICategory[] = await CategoryService.getCategoryList() commit('setCategoryList', data) } } const mutations: MutationTree = { setCategoryList: (state: CategoryState, payload: ICategory[]) => { state.categoryList = payload } } const category: Module = { namespaced: true, state, getters, actions, mutations }; export default category