Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async handleSubmit(event) {
- event.preventDefault()
- const { username, password } = this.state
- try {
- const response = await fetch('/log_in', {
- method: 'post',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ username, password })
- })
- }
- catch (error) {
- console.log(error)
- }
- }
- app.post('/log_in', (req,res) => {
- console.log(`login form data`);
- console.log(`Username : ${req.body.username}`);
- console.log(`password : ${req.body.password}`);
- if(req.body.username == "user" && req.body.password == "123"){
- res.redirect('/')
- }
- })
Add Comment
Please, Sign In to add comment