I have used following update method to update record in mongodb using nodejs. I feel something wrong with route i have given in the URL.In place of studentEmail in the route, i have given existing studetEmail address of the database.
app.put("/update/:studentEmail",(req,res)=>{
let upstudentEmail=req.params.studentEmail;
let upstudentName=req.body.studentName;
let upsection=req.body.section;
async function updatebyemail(studentEmail){
try{
//find and update
const result= await studentInfomodel.findOneAndUpdate({studentEmail:upstudentEmail},{$set:{studentName:upstudentName,section:upsection}},
{new:true});
console.log(result);
if(data==null){
res.send("nothing found")
}else{
res.send(data)
}
}catch{
console.error(error);
}
}
})