Apologies for delay in posting this article.
This article will help you to set up node js api in local machine. By using this api, you can work with frontend and integration with apis easily.
Also, you can use this api to work with my past and upcoming articles, most of my articles am using same api.
Please set up mongodb atlas(MongoDB Compass) in your local machine before setting up node js api. Click on below link to go to mongo dB atlas setup article.
Step 0. Once mongo DB atlas setup is done, then you can come to this article and do setup for node js api.
This article is only for setting up the node js api, meaning not teaching the node js code, just cloning my node js project, run and set up. Will show apis list and how apis work.
Note #1: Please copy the mongo dB connection string and keep it with you, I will tell you which file we need to paste that URL.
What is Node JS?
Before going to step 1, please install the node js in your local by using below link.
But my node js api supports version will be v14.15.0, Please download to avoid conflicts.
You can work with new version also, but you need to change the versions of npm packages and some of the code inside the app.
Step 1: Once mongodb atlas and node js installation done, Clone or download my node js api source code by using below url.
Click on Download ZIP button or copy clone URL. Am clicking on download zip button.
The file will be downloaded, extract the file and open the file by using vs code.
Step 2. Go to project directory, where you will see the package.json file. That location open command prompt and do npm install.
Step 3. Open project in vs code, the project structure will be look like below.
Step 4. Click on control + p and type index.js click enter to open the file.
After that, search for mongodb connection in code level,
Change process.env.MONGO_URI to mongodb atlas URI.
Sample URL looks like below.
Step 5: Once URI is updated, then do npm run dev in command prompt to run the node js api.
Step 6. Open node js api in chrome by using localhost:3000, You can see the list of public apis, you can access them without any token.
Step 7. click on public/users link, you can see the list of users data in json format and also you can integrate with this your frontend app.
Step 8. Up to now clear right, this way you can connect with my node js api with mongo dB atlas and use in frontend app.
Any issue found in node js api setup, please check it from the first step. If anything, miss in my article please write a mail or give me feedback on the comments section.
Happy Coding !!!,
Thanks for reading this article, This is Srikanth. Namaste !!!.
Please share your feedback, claps, and comments. In that way, it will have helped me to improve my articles in the future. Please share my story with your near and dear, also follow and subscribe to the medium