Mongoose FindByIdAndUpdate Successfully Updates Document But Ruturns Error
findByIdAndUpdate() successfully updates document, but returns error which i don't understand. Here is schema: const userSchema = mongoose.Schema({ phone: String, password:
Solution 1:
The body parameter can be a Buffer object, a String, an object, or an Array.
For it to work properly, use string interpolation:
User.findByIdAndUpdate( result.id, { "token": Date.now() },
(err, result) => {
// It gives error, of which stacktrace i give below. But if check database -
// everything is fine, token was updated successfully
if (err) return res.status(500).send(`Unable to create token. Error: ${err}`);
return res.status(200).send(`${result._id}, ${result.token}`);
})
Source: node-express error : express deprecated res.send(status): Use res.sendStatus(status) instead
Post a Comment for "Mongoose FindByIdAndUpdate Successfully Updates Document But Ruturns Error"