Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. // Action creator function
  2. function fetchArticles(params = {}) {
  3. return dispatch => {
  4. dispatch({ type: 'FETCH_ARTICLES_START', params });
  5. ArticlesService.getArticles(params).then(
  6. response => {
  7. dispatch({
  8. type: 'FETCH_ARTICLES_SUCCESS',
  9. data: response.data
  10. });
  11. },
  12. error => {
  13. dispatch({ type: 'FETCH_ARTICLES_FAILURE', error });
  14. }
  15. );
  16. };
  17. }
  18.  
  19. // Configuration
  20. const store = createStore(
  21. reducer,
  22. applyMiddleware(thunk)
  23. );
  24.  
  25. // Usage
  26. dispatch(fetchArticles());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement