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 all items GET endpoint

Create all items GET endpoint

From the course: MERN Essential Training (2020)

Start my 1-month free trial

Create all items GET endpoint

- [Instructor] Now let's work on the get endpoint, which will allow us to get all our players. So let's go ahead and go into the file called playerControllers if you're not already on it. And the first thing we're going to do is literally copy all that code here, and we'll change a few things. So let's copy that first. And then paste it on line 17. What I want to do here is change the function to getPlayers. It still takes a request and response, we can remove the let newPlayer. Like so and then what we're going to do is replace the player, dot save by player find and this is the function inside of mongo that will find all the players that we have. So I'm going to, add curly braces here and curly braces are for options. We're not going to pass any parameters for mongo but we could directly inside those curly braces. So then we have err and then player and then what we need to do the same function, if err send…

Contents