Help me understand why I get this error when I click on delete:

Cannot read property 'remove' of undefined 

I am just learning. maybe something in the code.
used Mongoose :

 router.delete('/contacts/:id', function(req,res){ Contacts.findById(req.params.id, function(err, user){ if(err){ res.send({message: "Error" + err}) } user.remove(function(err){ if(err){ res.send(err) } res.send({message: "Delete"}) }) }) }) 
  • Apparently, mongoose cannot find the user (user) by this id, as there is no user with such id. - teqwry
  • The user object does not have a remove property, which you have is a function reference. - Sublihim

0