June 2018
Intermediate to advanced
348 pages
8h 19m
English
Deleting a team is extremely easy. To do this, we will call the remove built-in method of the Team model. Add the following code:
....delete((req, res, next) => { let id = req.params.id Team.remove({_id: id}) .then(result => res.json(result)) .catch(err => next(err)) })module.exports = api
Now, let's test things out. Execute the following command:
$ curl -X DELETE http://localhost:3000/teams/5a662fbf728726072c6298fc{"n":1,"ok":1}
The output is a bit different now; we received a JSON object with two params:
Awesome! Now we have our Rest API to manage our teams ready, but there is a key missing piece in our API that we did not take care of, ...
Read now
Unlock full access