showing results for - "mongoose delete request"
Luca
05 Jul 2019
1// The "todo" in this callback function represents the document that was found.
2// It allows you to pass a reference back to the client in case they need a reference for some reason.
3Todo.findByIdAndRemove(req.params.todoId, (err, todo) => {
4    // As always, handle any potential errors:
5    if (err) return res.status(500).send(err);
6    // We'll create a simple object to send back with a message and the id of the document that was removed
7    // You can really do this however you want, though.
8    const response = {
9        message: "Todo successfully deleted",
10        id: todo._id
11    };
12    return res.status(200).send(response);
13});
14