Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | import getArticles from './services'; export function articlesHasErrored(bool) { return { type: 'ARTICLES_HAS_ERRORED', hasErrored: bool, }; } export function articlesIsLoading(bool) { return { type: 'ARTICLES_IS_LOADING', isLoading: bool, }; } export function articlesFetchDataSuccess(articles) { return { type: 'ARTICLES_FETCH_DATA_SUCCESS', payload: articles, }; } export function articlesFetchData() { return async (dispatch) => { dispatch(articlesIsLoading(true)); try { const items = await getArticles(); dispatch(articlesIsLoading(false)); dispatch(articlesFetchDataSuccess(items)); } catch (e) { dispatch(articlesHasErrored(true)); } }; } |