MongoDB and Mongoose - Delete One Document Using model.findByIdAndRemove

Tell us what’s happening:

Delete One Document Using model.findByIdAndRemove
Here is my code

var removeById = function(personId, done) {
  Person.findByIdAndRemove(personId, (err, removedPerson) => {
      if(err) 
         return console.log(err);
      done(null, removedPerson);
    }
  ); 
};

but it doesn’t work and saying
Delete item should success
any one help me, please

###Your project link(s)

solution: https://3000-freecodecam-boilerplate-ufvsxctbqct.ws-eu110.gitpod.io

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/125.0

Challenge Information:

MongoDB and Mongoose - Delete One Document Using model.findByIdAndRemove

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

There are no var declarations or standard function definitions in the current boilerplate. So unless you changed it, you must have an old version of the boilerplate.

Get the latest version and try again because the code you posted is passing for me.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.