Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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
You can’t perform that action at this time.