Skip to content

Instantly share code, notes, and snippets.

@charly-palencia
Created June 14, 2019 04:15
Show Gist options
  • Select an option

  • Save charly-palencia/bf1e564974331320f80aa18e9de8e34f to your computer and use it in GitHub Desktop.

Select an option

Save charly-palencia/bf1e564974331320f80aa18e9de8e34f to your computer and use it in GitHub Desktop.
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