Skip to content

Instantly share code, notes, and snippets.

@mercykip
Created July 19, 2021 11:11
Show Gist options
  • Select an option

  • Save mercykip/fce2714863843aeca6957319f96b26db to your computer and use it in GitHub Desktop.

Select an option

Save mercykip/fce2714863843aeca6957319f96b26db to your computer and use it in GitHub Desktop.
/// action creator which gets user data from an API
export const getUserAction = (id) => {
return (dispatch) => {
axios.get(`https://ti-react-test.herokuapp.com/users/${id}`)
.then(response => {
console.log(response);
dispatch(getUser(response.data)
);
})
.catch(error => {
console.log(error);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment