title: Unable to query data using Postman
body: <p>I've set a Node.js server and trying to query data (from MySQL) through Postman. <code>Select * from table</code> works perfectly fine but when I read the input through <code>req.body.foo</code> Node.js throws me an error:</p>
  
  <blockquote>
    <p>Cannot read property 'length' of undefined</p>
  </blockquote>
  
  <p>Server.js:</p>
  
  <pre><code>var app = require('express')(); // Express App include
  var http = require('http').Server(app); // http server
  var mysql = require('mysql'); // Mysql include 
  var bodyParser = require("body-parser"); // Body parser for fetch posted data
  var connection = mysql.createConnection({ // Mysql Connection
  host : 'localhost',
  user : 'root',
  password : 'mayur',
  database : 'mayur',
  });
  
  app.use(bodyParser.urlencoded({ extended: true }));
  app.use(bodyParser.json());
  
  app.get('/',function(req,res){
  
  connection.query("SELECT * from login where username= ?? ", req.body.username ,function(err, rows, fields){
      if(rows.length != 0){
          res.json(rows);
  
      }else{
          var data = 'No users Found..';
          res.json(data);
      }
  });
  });
  
   app.listen(3030);
  </code></pre>