import get from 'lodash/object/get'; import axios from 'axios'; import ItemStore from '../stores/ItemStore'; export default actionGenerator('ItemAction', { async fetchItem({ context, payload }) { const id = get(payload, ['entity', 'item', 'id']); const res = await axios.get(`/api/items/${id}.json`); const item = get(res, ['data', 'data']); context.dispatch(ItemStore.dispatchTypes.SET_ITEM, { item }); }, });