Skip to content

Instantly share code, notes, and snippets.

@tapandave08
Created November 17, 2017 08:01
Show Gist options
  • Save tapandave08/f0699d00f79ce6f9eefa339a00979930 to your computer and use it in GitHub Desktop.
Save tapandave08/f0699d00f79ce6f9eefa339a00979930 to your computer and use it in GitHub Desktop.
export const fetchPOSTLOGIN = creds => {
return dispatch => {
dispatch({ type: LOGIN_REQUEST, payload: true });
login(creds)
.then(user => {
sessionStorage.setItem("token", user.token);
dispatch({ type: LOGIN_SUCCESS, payload: user.token });
history.push(`/dashboard`);
})
.catch(err => {
dispatch(
errornotification(notification(errorcatc(err), "Error While Login"))
);
dispatch({ type: LOGIN_FAILURE });
});
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment