In this video we are going to learn about Handling the post request.
POST and GET are two common HTTP Request used for building REST API's.
Both of these calls are used for some special purpose.
GET request are used to fetch data from specified resource and POST are used to submit data to a specified resource.
Express version 4 and above require extra middle-ware layer to handle a POST request.
This middle-ware is called as 'bodyParser'.
So let install the body parser.
So go to the command prompt and run the command.

npm install body-parser

Now we have to import this package in our project and tell Express to use this as middle-ware.
So go to the index.js and import the package.

var bodyParser = require(\"body-parser\");

Now configure express to use body parser as middleware.

app.use(bodyParser.urlencoded({ extended: false }));

Now we can use express router to handle POST request.
Now create a route.


Now create a view.
So go to the views and create new file login.ejs.
Now open login.ejs and write the following code.

<!DOCTYPE html>
<html lang=\"en\">
<meta charset=\"UTF-8\">
<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
<form method=\"POST\" action=\"/post\">
<div class=\"form-group\">
<label for=\"email\">Email </label>
<input type=\"email\" class=\"form-control\" id=\"email\">
<div class=\"form-group\">
<label for=\"password\">Password</label>
<input type=\"password\" class=\"form-control\" id=\"password\">
<button type=\"submit\" class=\"btn btn-primary\">Submit</button>

Add create the post route.
So go to the index.js and lets create the route.'/post',function(request,response){
var password=request.body.password;
res.send('Email'+email + \" Password: \"+password);

Now lets run this.
So go to the command prompt and run the index.js file.

node index.js

Now its running.
So go to the browser an.
Just go to the url /login.
Now fill email and password here and click on submit button.
You can see here the email and password has been submitted.
So in this way you can handle the post request.