-
Install the dependencies that you will need in the process
-
You can check out for dependencies at https://www.npmjs.com/
-
The first few dependencies that you need to download are :
- http
- express
- mongoose
-
You can add these dependencies simply by running simple command in server terminal
-
Connection Building
- the below code is written to check if server is working or not in Index.js
- That would be the output we get on running index.js
- Installing another dependency i,e dev dependency that will help us to break the loop , when you will run the above code it will kept running and you have to terminate the whole process, so to avoid that we will be using NODEMON DEPENDENCY.
- Now to activate the nodemon, you have to write a script in package.json
Creating API
- Now we are creating our First API
- Now go to your server terminal and run the command
- Now your server is running. Go to your browser and write the below URL.
- As you can see it is giving *Cannot Get /* msg this is because we have not given the correct path that will show us the JSON quoted msg, check out the above API code, you will get it whats the right path to get result.
- Adding 2 Get Requests at 2 paths
- Our Default Path will look like this removing the Cannot Get /
- The /helloworld path