title: Request body is empty in nodejs express post request
body: <p>i have troubles to send simple json data from javascript ajax client to nodejs express rest api.</p>
  
  <p>Here is the server side code: </p>
  
  <pre><code>    //POST api/login
  app.post('/api/login', (req, res) =&gt; {
    console.log(req.body)//here the body always empty object
    var body = _.pick(req.body, ['email', 'password'])
    console.log(body)
    var user;
    User.findByCredentials(body.email, body.password).then((result) =&gt; {
      user = result
      return user.generateAuthToken()
    }).then((token) =&gt; {
      res.status(200).header('x-auth', token).send(user)
    }).catch((e) =&gt; {
      res.status(400).send('Unauthorized')
    })
  
  })
  </code></pre>
  
  <p>Here is the client side:</p>
  
  <pre><code>$(document).ready(function(){
  
    jQuery('#login-form').on('submit', function(e){
      e.preventDefault()
      var username = jQuery('[name=username]').val()
      var password = jQuery('[name=password]').val()
  
      if(username &amp;&amp; password){
        let dataToSend = {
          "email":username,
          "password":password
        }
  
        console.log(dataToSend)
        $.ajax({
          url:"http://192.168.1.22:3000/api/login",
          type: "POST",
          data: dataToSend,
          headers: { 
            'Access-Control-Allow-Origin':"*",
            'Content-Type': 'application/json; charset=utf-8',
            Accept: 'application/json'
          },
          dataType: 'json',
          cache: false,
          success: function(data){
            console.log('on success : '+data);
          },
          error: function(e){
            console.log("login error, status: "+e.status +" message : 
                                                   "+e.responseText);
          }
        })
      }
    })
  })
  </code></pre>
  
  <p>The problem is if i send the request like this i get crash error on server side :</p>
  
  <pre><code>SyntaxError: Unexpected token e in JSON at position 0
      at JSON.parse (&lt;anonymous&gt;)
      at createStrictSyntaxError (D:\NodeJs-Projects\location-tracker-server\node_modules\body-parser\lib\types\json.js:158:10)
      at parse (D:\NodeJs-Projects\location-tracker-server\node_modules\body-parser\lib\types\json.js:83:15)
      at D:\NodeJs-Projects\location-tracker-server\node_modules\body-parser\lib\read.js:121:18
      at invokeCallback (D:\NodeJs-Projects\location-tracker-server\node_modules\raw-body\index.js:224:16)
      at done (D:\NodeJs-Projects\location-tracker-server\node_modules\raw-body\index.js:213:7)
      at IncomingMessage.onEnd (D:\NodeJs-Projects\location-tracker-server\node_modules\raw-body\index.js:273:7)
      at emitNone (events.js:106:13)
      at IncomingMessage.emit (events.js:208:7)
      at endReadableNT (_stream_readable.js:1056:12)
      at _combinedTickCallback (internal/process/next_tick.js:138:11)
      at process._tickCallback (internal/process/next_tick.js:180:9)
  </code></pre>
  
  <p>If i remove the headers data from request it will not crash but i always receive empty body at server, and the most annoying is if i make the same request from android native client with okHttp library all work perfect.
  Do i miss something?</p>