Build User Authentication and perform API Testing
Part 3
In the last part we will build a auth and perform API testing using postman
In this series we will be creating a simple Node.js API for User-Authentication firstly creating routes , handling API request then connecting it with the MongoDB Atlas and performing Database operations on MongoDB collections using postman
Before moving forward have a look at Part 1 and Part 2 of the series
Step 1:- Build routes , register and login
The .findOne method compares the email value from frontend (req.body.email) with the email value from database
Step 2:- Setup Postman For Testing
Postman is a software that acts as a frontend to send http requesrs to the server and also show the response for the corresponding request sent.
Create a new collection and then Add a request in that collection, as we will be sending data to the server so it will be a POST request. Change the body data to raw and JSON , follow the below Screenshots . Important part the we need is to parse the JSON file so add app.use(express.json()) in your index.js file or else it wont be able to read the data sent from postman
Step 3 : Nodemon index.js
Start your server and make sure its running and connected to MongoDB. First we will make post request at our register , consider above attached screenshots. Create a json and then pass it by clicking send and Boom!!! you will see the results. Similarly change the url for Login and pass the data. Boom returns!!! .
We created a basic authentication system further we will be working and integrating JWT Token for Web Authorization.
You can clone the repository and perform Postman testing by yourself, make sure to create your own MongoDB Database and connect it to the server
Github Repository :- https://github.com/Radhaiya/Node-Project.git