Last active
November 8, 2019 16:56
-
-
Save koptionalsoftware/7a7a6bf745192d95a0e90c90e2a90934 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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