router.delete('/user/:userId', (req ,res) => {
User.findOneAndRemove(req.params.userId, (err, doc) => {
if(!err) { res.send(doc); }
else {console.log('Error in Insurance agent Delete :' + JSON.stringify(err, undefined, 2)); }
});
});
答案 0 :(得分:0)
findOneAndRemove()
方法需要一个对象作为查询参数。所以代替:
User.findOneAndRemove(req.params.userId, (err, doc) => {
使用此:
User.findOneAndRemove({userId: req.params.userId}, (err, doc) => {