Skip to content

Instantly share code, notes, and snippets.

@NetguruGist
Created January 10, 2017 11:27
Show Gist options
  • Save NetguruGist/2ca5ab65a6e31aca7e7f5ea7ef4162e4 to your computer and use it in GitHub Desktop.
Save NetguruGist/2ca5ab65a6e31aca7e7f5ea7ef4162e4 to your computer and use it in GitHub Desktop.
export const fetchQuotes = () => dispatch => {
dispatch({ type: 'FETCH_QUOTES_REQUEST'});
return fetch('/api/random-quote')
.then(r => r.json())
.then(({ quotes }) => {
dispatch({
type: 'FETCH_QUOTES_SUCCESS',
data: quotes,
});
})
.catch(() => {
dispatch({ type: 'FETCH_QUOTES_FAILURE' });
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment