Created
December 21, 2018 17:29
-
-
Save jamesseanwright/430d183150efcbe826e30a3929746e98 to your computer and use it in GitHub Desktop.
Redux Thunk Example
This file contains hidden or 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 addRonSwansonQuote = () => | |
| (dispatch: React.Dispatch<Action>) => { | |
| dispatch(setQuoteLoading()); | |
| return fetch('https://ron-swanson-quotes.herokuapp.com/v2/quotes') | |
| .then(res => res.json()) | |
| .then(([quote]: string[]) => | |
| dispatch(addMessage(quote)), | |
| ) | |
| .catch(() => dispatch(setQuoteError())); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment