Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. async handleSubmit(event) {
  2. let userLoginObject = {
  3. login: this.state.username,
  4. password: this.state.password,
  5. }
  6. if (!isEmptyOrNull(this.state.username) &&
  7. !isEmptyOrNull(this.state.password)) {
  8. let resp = await this.props.onUserLogin(userLoginObject)
  9. console.log("resp",resp) // this shows 'undefined'
  10. this.setState({ formError: resp }); //Im trying to set state to the formError
  11. }
  12. }
  13.  
  14. export const onUserLogin = (userLoginData) => async (dispatch) => {
  15. const loginResponse = await doUserLogin(userLoginData)
  16. dispatch({
  17. type: ACTION_LOGIN,
  18. data: loginResponse,
  19. })
  20. if (loginResponse.token) {
  21. history.push('/investments')
  22. }
  23. else {
  24. console.log("error",loginResponse.error) // this shows the error message
  25. return loginResponse
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement