Hi team: I’ve been googling this all day but can’t figure out my error, I’ve reached the end of Ali’s Mongodb and node.js tutorial but keep getting a null error with my code:
I can create, fetchAll and delete notes but can’t update. I think this must mean that the id search query is finding nothing but can’t see the typo/error! Any advise would be great!!
app.post("/update", (req, res) => {
Data.findOneAndUpdate(
{
_id: req.get ("id") },
{title: req.get ("title"),
date: req.get ("date"),
note: req.get("note")
},
(err) => {
console.log ("Failed to update ", + err)
})
res.send ("Updated")
})