From the course: MERN Essential Training
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Setup your database
From the course: MERN Essential Training
Setup your database
- [Instructor] We are now ready to set up our database inside of our API, so let's get to it. So let's close these files for now, and what we're going to do is load the index.js and I'm going to close the explorer just to have a little bit more screen here, and what I'm going to do now is import mongoose first, which are going to be the tool that we're going to use to do transactions with our MongoDB. It simplifies the syntax versus doing straight command to the Mongo server. We're also going to import bodyparser. We're going to import cors from cors, and cors allows us to do transactions with different domains. So basically cross-transactional. So if you're having issues doing specific transactions with a backend, that's usually one of the issue. You can read more on cors online if you want to research it. And we're going to set up our routes right away. One thing that is certain is once we import our routes inside the index.js file, and we haven't set up any routes yet, A, it's…