Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement