`router.post("/users", async (req, res) => {
if(!req.body){
res.status(400).send({ message : "Content can not be emtpy!"});
return;
}
// new user
const user = new Userdb({
id : req.body.id,
name : req.body.name,
phone : req.body.phone,
village: req.body.village
})
// save user in the database
user
.save(user)
.then(data => {
//res.send(data)
res.redirect('/add-user');
return;
})
.catch(err =>{
res.status(500).send({
message : err.message || "Some error occurred while creating a create operation"
});
return;
});
// res.render('index')
});`
Top comments (0)