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 specific ID GET endpoint

Create specific ID GET endpoint

From the course: MERN Essential Training (2020)

Start my 1-month free trial

Create specific ID GET endpoint

Now let's work on the ID get endpoint, which will allow us to get a single player. Let's go ahead and start with the controllers and it's pretty much the same process as we've done before. So if you want to test yourself and challenge yourself to write the code first, go ahead and press pause and do it and then come back to the video. And I'm just going to go ahead and continue. I'm going to copy this block of code. Lines 17 through 24, paste it, and then change the name to getPlayerwithID. Same requests, same response. And now as opposed to Player.find It's findById. Like so. And now we're going to pass a few things before we get to our response here. What we're going to need to do is remove the curly braces and we're going to pass the req.params.PlayerID, So basically when we send the request to get a specific player with ID, we're going to have an ID. So basically the ID of the players. So if we go back to…

Contents