Skip to content

Instantly share code, notes, and snippets.

@Tauka
Last active April 15, 2017 23:42
Show Gist options
  • Select an option

  • Save Tauka/85a33b49a3f58f428d814b3d3a116b55 to your computer and use it in GitHub Desktop.

Select an option

Save Tauka/85a33b49a3f58f428d814b3d3a116b55 to your computer and use it in GitHub Desktop.
export function typicalAction() {
return function(dispatch) {
dispatch({type: "ACTION_PENDING"});
fetch(`http://someapi/user`)
.then((response) => {
dispatch({type: "ACTION_SUCCESS", payload: response});
})
.catch((err) => {
dispatch({type: "ACTION_FAIL", payload: err });
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment