title: how to stop body-parser from returning undefined in nodejs application
body: <pre><code>var http = require('http');
  var express = require('express');
  var app = express();
  var server = require('http').Server(app);
  var io = require('socket.io').listen(server);
  var path = require('path');
  var mysql = require('mysql');
  var bodyParser = require('body-parser');
  var jsonParser = bodyParser.json({type: 'application/json'});
  var cookieParser = require('cookie-parser');
  var cors = require('cors');
  app.use('*', cors());
  app.set('views', path.join(__dirname, 'views'));
  app.use(express.static(path.join(__dirname, 'public')));
  // parse application/x-www-form-urlencoded
  app.use(bodyParser.urlencoded({ extended: false }))
  
  // parse application/json
  app.use(bodyParser.json({type: 'application/json'}));
  app.use(cookieParser());
  </code></pre>
  
  <p>here is my client side code using jquery API</p>
  
  <pre><code>$.ajax({
          url: "/checkIfAdmin",
          type: 'GET',
          data: JSON.stringify({'password': 'password', 'username': 'username'}),
          crossDomain: true,
          async: true,
          cache: false,
          contentType: "application/json; charset=utf-8",
          processData: false,
          success: function (data) {
                 // doing something
          },
          error: function(data){
               // throw error here!
          }
  });
  </code></pre>
  
  <p>Body parser has been returning an empty body, being trying to fix this now for a while, on app route below </p>
  
  <pre><code>app.get('/checkIfAdmin', jsonParser, function(req, res){
       console.log(req.body);
       // Am getting an empty object ie {}
  });
  </code></pre>
  
  <p>am getting { } (empty object)
  please how do I fix this</p>