Skip to content
Permalink
4828ba6c13
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
53 lines (37 sloc) 1.06 KB
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