Guest User

Untitled

a guest
Dec 10th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. axios.post('http://localhost:3000/api/v1/login', {
  2. email: this.state.email,
  3. password: this.state.password
  4. }, {
  5. headers: {
  6. "Access-Control-Allow-Origin": "*",
  7. "Access-Control-Allow-Credentials": true,
  8. "Access-Control-Allow-Methods": "GET,HEAD,OPTIONS,POST,PUT,DELETE",
  9. "Access-Control-Allow-Headers": "",
  10. }
  11. })
  12. .then(function (response) { this.onloginSuccess(response) })
  13. .catch(function (error) { this.onLoginFail(error)});
  14.  
  15. onloginSuccess = (response) => {
  16. console.log(response)
  17. this.setState({
  18. buttonDisable: false
  19. });
  20.  
  21. sessionStorage.setItem('uuid', response.value.data.uuid)
  22. sessionStorage.setItem('bearertoken', response.value.data.bearertoken)
  23.  
  24.  
  25. this.props.history.push({ pathname: '/dashboard' })
  26. }
  27.  
  28. onloginFail = (error) => {
  29. NotificationManager.error(error.response.data.message, 'Error!', 5000);
  30. this.setState({
  31. buttonDisable: false
  32. });
  33. }
  34.  
  35. Uncaught (in promise) TypeError: Cannot read property 'onLoginFail' of undefined
  36. at eval (index.js?8a7d:95)
  37.  
  38. index.js?8a7d:94 Uncaught (in promise) TypeError: Cannot read property 'onloginSuccess' of undefined
  39. at eval (index.js?8a7d:94)
Add Comment
Please, Sign In to add comment