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:
- Go to MongoDB website mongoDB and create your free account by signing up or signing in using your Google account.
2.Create a cluster.
Choose Shared Clusters which is free.
Now you can choose AWS and North Virginia region which mostly people use and then click on Create Cluster at the bottom.
It will take few minutes in cluster creation.
3.Now create user.
Authenticate the user by giving username,password and choosing Database user privileges-Read and write to any database.
4.Now go to Network access and whitelist your IP Address.
Choose your current IP address and confirm.
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.
Now connect your application.
Now copy the link which you will use in your project.Replace the password in the link with the actual password you set before.
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.
Top comments (1)
Thanks Michael :)