Created
January 10, 2017 11:27
-
-
Save NetguruGist/2ca5ab65a6e31aca7e7f5ea7ef4162e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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