Guest User

Untitled

a guest
Feb 9th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. async handleSubmit(event) {
  2. event.preventDefault()
  3. const { username, password } = this.state
  4.  
  5. try {
  6. const response = await fetch('/log_in', {
  7. method: 'post',
  8. headers: { 'Content-Type': 'application/json' },
  9. body: JSON.stringify({ username, password })
  10. })
  11. }
  12.  
  13. catch (error) {
  14. console.log(error)
  15. }
  16. }
  17.  
  18. app.post('/log_in', (req,res) => {
  19. console.log(`login form data`);
  20. console.log(`Username : ${req.body.username}`);
  21. console.log(`password : ${req.body.password}`);
  22. if(req.body.username == "user" && req.body.password == "123"){
  23. res.redirect('/')
  24. }
  25. })
Add Comment
Please, Sign In to add comment