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 the POST endpoint
From the course: MERN Essential Training (2020)
Create the POST endpoint
- [Instructor] In this video, we'll complete our post endpoints, so we can add new items to our database, so let's get to it. So the first thing we're going to do is get back into the player controllers, inside of the controllers folder. So if you don't have that file open, you open the controllers folder, and then playerControllers.js. And then let's go ahead and start coding. So the first thing we're going to do is import mongoose from mongoose. Then we'll import. What I'm going to do next is use a specific trick when I want to import specific function from a file, so let's do the from first, like so, models and then playerModel. And then what we're going to do, as we type anything in between the curly braces it's going to autocomplete for us because we've already imported the file, like so. Perfect, so now what I'm going to do is create a Player from the mongoose model that we just imported, so Player from the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.