Request body is null for POST request in NodeJS
<p>I have the below code. when I make a Post request via Postman I get <code>req.body</code> as undefined.</p>

<p>Post Request is <code>http://localhost:1702/es</code>.</p>

<p>Body:</p>

<pre><code>{
  "ip_a":"191.X.X.XX",
  "pkts":34    
}
</code></pre>

<p>and <code>Content-Type:"application/json"</code>. I also used <code>application/x-www-form-urlencoded</code> but got the same result.</p>

<p>My app.js is:</p>

<pre><code>var express = require('express');
var es=require('./routes/es');
var app = express();
app.post('/es',es.postesdata);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
</code></pre>

<p>And my file where I am receiving a request body null is:</p>

<pre><code>exports.postesdata=function(req,res){

    var body=req.body;

    console.log(body);//Getting Undefined here 

}
</code></pre>

<p>Am I doing something wrong here?</p>