MongoDB setup for creating REST API

kritika27

Kritika Srivastava

Posted on March 3, 2021

MongoDB setup for creating REST API

Here I am going to explain how to set up your database MongoDB for creating REST API using node.js,express which you can later fetch using any frontend like React.I am not covering the basics of mongoDB here.

Steps to be followed:

  1. Go to MongoDB website mongoDB and create your free account by signing up or signing in using your Google account. Alt Text

Alt Text

Alt Text

2.Create a cluster.
Alt Text
Choose Shared Clusters which is free.
Alt Text
Now you can choose AWS and North Virginia region which mostly people use and then click on Create Cluster at the bottom.
Alt Text
It will take few minutes in cluster creation.
Alt Text

3.Now create user.
Alt Text
Authenticate the user by giving username,password and choosing Database user privileges-Read and write to any database.
Alt Text

4.Now go to Network access and whitelist your IP Address.
Alt Text
Choose your current IP address and confirm.

Alt Text
You will only be able to connect to your cluster from the list of IP Addresses in IP Access List.

5.Now go to Clusters and choose Connect.
Alt Text
Now connect your application.
Alt Text
Now copy the link which you will use in your project.Replace the password in the link with the actual password you set before.
Alt Text

Now you can use this link to connect to database in your REST API or MERN stack if you work in React or any other frontend.

Happy Learning :)
You can follow me on Twitter and Github.

💖 💪 🙅 🚩
kritika27
Kritika Srivastava

Posted on March 3, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related