blob: 5d250b2e29e14033a96a0d49baa2c8242ac38b1c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
import * as types from './mutation_types';
export default fetchItems => ({
requestItems: ({ commit }) => commit(types.REQUEST_ITEMS),
receiveItemsSuccess: ({ commit }, payload) => commit(types.RECEIVE_ITEMS_SUCCESS, payload),
receiveItemsError: ({ commit }, payload) => commit(types.RECEIVE_ITEMS_ERROR, payload),
fetchItems: ({ dispatch }, payload) => {
dispatch('requestItems');
return fetchItems(payload)
.then(items => dispatch('receiveItemsSuccess', { items }))
.catch(error => dispatch('receiveItemsError', { error }));
},
});
|