REST API Delete – Remove Mongo DB Record

Delete a record in Mongo DB database using express js code. DELETE Request in REST API sample code example.

app.route('/articles/:articleTitle').delete(function(req,res){

  Article.deleteOne({title: req.params.articleTitle}, function(err){
    if(err){
      res.send(err);
    }else{
      res.send("Successfully deleted Item");
    }
  })

});

About the Author: smartcoder

You might like

Leave a Reply

Your email address will not be published. Required fields are marked *