Guest User

Untitled

a guest
May 7th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. onSubmitSignIn = () => {
  2. console.log(this.state.signInPassword);
  3. fetch('http://localhost:3000/signin', {
  4. method: 'post',
  5. headers: {'Content-Type': 'application/json'},
  6. body: JSON.stringify({
  7. name: this.state.signinName,
  8. password: this.state.signinPassword
  9. })
  10. })
  11. .then(response => response.json())
  12. .then(user => {
  13. if(user.id){
  14. this.props.loadUser(user);
  15. this.props.onRouteChange('home');
  16. }
  17. })
  18. }
  19.  
  20. app.post('/signin', (req, res) => {
  21. const { name, password } = req.body;
  22.  
  23. console.log("FRONT END : ", password);
  24. console.log("BACK END: ", database[0].password);
  25. console.log("FRONT END : ", name);
  26. if(name == database[0].name && password == database[0].password){
  27. res.json(database[0]);
  28. }else{
  29. res.status(400).json("Couldn't get user");
  30. console.log('didnt work');
  31. }
  32. })
Add Comment
Please, Sign In to add comment