Last active
July 9, 2019 06:08
-
-
Save jtomaszewski/fd6c3c1e0696cf0b5d11c3fef6f616e2 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
// Action creator function | |
function fetchArticles(params = {}) { | |
return dispatch => { | |
dispatch({ type: 'FETCH_ARTICLES_START', params }); | |
ArticlesService.getArticles(params).then( | |
response => { | |
dispatch({ | |
type: 'FETCH_ARTICLES_SUCCESS', | |
data: response.data | |
}); | |
}, | |
error => { | |
dispatch({ type: 'FETCH_ARTICLES_FAILURE', error }); | |
} | |
); | |
}; | |
} | |
// Configuration | |
const store = createStore( | |
reducer, | |
applyMiddleware(thunk) | |
); | |
// Usage | |
dispatch(fetchArticles()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment