SHARE
TWEET

Untitled

a guest Jul 18th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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());
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top