Skip to content

Instantly share code, notes, and snippets.

@asherccohen
Created June 19, 2019 17:20
Show Gist options
  • Save asherccohen/4590afd5d9c4ec861392a42d23c47462 to your computer and use it in GitHub Desktop.
Save asherccohen/4590afd5d9c4ec861392a42d23c47462 to your computer and use it in GitHub Desktop.
// todo/actions.js
export const getEvents = (dispatch) => () => {
dispatch({ type: 'GET_EVENTS_REQUEST' });
return fetch('/api/v1/events')
.then((todos) => dispatch({ type: 'GET_EVENTS_SUCCESS', payload: todos })
.catch((error) => dispatch({ type: 'GET_EVENTS_FAILURE', payload: error, error: true });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment