Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sports_Club/login.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
53 lines (37 sloc)
1.06 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const router = express.Router() | |
const User = require('../models/user') | |
router.post('/',async(req,res)=>{ | |
var email = req.body.email; | |
var password = req.body.password; | |
const username=await User.findOne({email:email | |
,password:password}); | |
console.log(username); | |
if(username==null) | |
{ | |
return res.status(400).json("False") | |
} | |
try{ | |
res.status(200).json(username) | |
} | |
catch(err){ | |
res.status(201).json({message:err.message}) | |
} | |
}) | |
// router.post('/',async(req,res)=>{ | |
// console.log(req.body.name); | |
// const user=new User({ | |
// name:req.body.name, | |
// email:req.body.email, | |
// password:req.body.password, | |
// type:req.body.type | |
// }) | |
// try{ | |
// const newUser=await user.save() | |
// res.status(201).json(newUser) | |
// } | |
// catch(err){ | |
// res.status(201).json({message:err.message}) | |
// } | |
// }) | |
module.exports = router |