Answer the question
In order to leave comments, you need to log in
PUT request does not work. Data in Mongodb doesn't change?
Hello!!! When working with the mongodb database, all queries work fine, except for PUT. >Cannot PUT /notes/5fe45811e6c6cc363004c238. And 404 drops out. What could be the problem?
app.put ('/notes/:id', (req, res) => {
const myDB = database.db('test');
const id = req.params.id;
const details = { '_id': new ObjectID(id) };
const note = { text: req.body.body, title: req.body.title };
myDB.collection('notes').update(details, note, (err, result) => {
if (err) {
res.send({'error':'An error has occurred'});
} else {
res.send(note);
}
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question