Skip to content

Instantly share code, notes, and snippets.

@koptionalsoftware
Last active November 8, 2019 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koptionalsoftware/7a7a6bf745192d95a0e90c90e2a90934 to your computer and use it in GitHub Desktop.
Save koptionalsoftware/7a7a6bf745192d95a0e90c90e2a90934 to your computer and use it in GitHub Desktop.
// Example module
import api from './api';
import {
FETCH_DATA
} from './actions.types.js';
import {
FETCH_DATA_START,
FETCH_DATA_SUCCESS,
FETCH_DATA_FAILURE
} from './mutations.types.js';
const initialState = () => ({
})
const getters = {
};
const mutations = {
[FETCH_DATA_START](state){
},
[FETCH_DATA_SUCCESS](state){
},
[FETCH_DATA_FAILURE](state){
},
};
const actions = {
[FETCH_DATA]({commit}) {
commit(FETCH_DATA_START);
return api.get('/data').then(resp => {
commit(FETCH_DATA_SUCCESS, resp);
}).catch((err) => {
commit(FETCH_DATA_FAILURE);
throw err;
})
}
};
export default {
getters,
mutations,
actions,
state : initialState
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment