From the course: MERN Essential Training (2020)

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Create a DELETE endpoint

Create a DELETE endpoint

From the course: MERN Essential Training (2020)

Start my 1-month free trial

Create a DELETE endpoint

- [Tutor] Now let's work on the delete endpoint, which will allow us to delete players. So we're back in the playerControllers, right here, and what we're going to do for the delete, we're going to copy and paste again, not this one, let's go up to this one here. Because it's going to be more similar to the getplayerwithID than the UpdatePlayer, so let's copy that one and let's paste it here, and we're going to call this deletePlayer, as you probably have guessed and it takes requests, response, player, and as opposed to findById it's remove, and then what we need for the actual parameters, we need the ID, so we can literally copy this one here like so and paste this here, and we have everything we need. So after that, it's going to go through the error player, error message, if something goes wrong and then as opposed to returning a player because we don't have a player, we need to return a message. So we'll remove that and…

Contents