Created
June 14, 2019 04:15
-
-
Save charly-palencia/bf1e564974331320f80aa18e9de8e34f to your computer and use it in GitHub Desktop.
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
| import { UPDATE_COLOR } from "../actionTypes"; | |
| const successFetchColor = (colorResponse) => { | |
| return { | |
| type: UPDATE_COLOR, | |
| color: `#${colorResponse["new_color"]}` | |
| }; | |
| } | |
| export const fetchColor = () => ( | |
| dispatch => { | |
| fetch("http://www.colr.org/json/color/random") | |
| .then((response) => response.json()) | |
| .then((response) => { | |
| dispatch(successFetchColor(response)) | |
| }); | |
| } | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment