Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save mercykip/a2436dc649ca0c0361943ecf5b0289da to your computer and use it in GitHub Desktop.
/// add a new user
export const addUserAction = (user) => {
return (dispatch) => {
/// axios is a library used to make request to an API,
/// return data and manipulate the data .
axios.post('https://ti-react-test.herokuapp.com/users', user)
.then(response => {
console.log(response);
dispatch(addUser(response.data))
})
.catch(error => {
console.log("eror", error);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment