title: express parsing json with body-parse
body: <p>I'm trying to use body-parse version 1.18.3 with express to parse a json post. In app.js I've included it like so</p>
  <h1>app.js</h1>
  <pre><code>var express = require('express');
  var session = require('express-session');
  var bodyParser = require('body-parser');
  
  ...
  
  //App setup
  var app = express();
  
  // create application/json parser
  var jsonParser = bodyParser.json()
  
  app.set('trust proxy', 1) // trust first proxy
  // Use the session middleware
  app.use(session({ secret: 'secretletters', cookie: {}}))
  
  app.post('/', jsonParser, function (req, res) {
    console.log(req.body);
    if (req.session.username) {
  
    } else {
  
    }
  
    res.send({'status': 'ok'})
  });
  </code></pre>
  <p>and in my script on the frontend send a username back to it</p>
  <pre><code>$('.login-btn').click(function() {
      let username = $('.username').val();
  
      if (username == '') {
          $('.login-error').removeClass('hidden');
          return null;
      }
      //if passed hide error
      $('.login-error').addClass('hidden');
  
      var data = {
          'username': username
      }
  
      $.ajax({
          url: &quot;/&quot;,
          type: &quot;POST&quot;,
          dataType: 'json',
          data: JSON.stringify(data),
          success: function(response){
             
          },
          error: function(xhr){
              
          },
  
  
      });
  
      /* End Ajax Call */
  
  
  });
  </code></pre>
  <p>It send the username successfully, here's a screenshot of the results of the post request from the network tools</p>
  <p><a href="https://i.stack.imgur.com/Z6qVh.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z6qVh.jpg" alt="enter image description here" /></a></p>
  <p>the bug is when on <code>console.log(req.body);</code> on <code>app.post</code> I get back and empty <code>{}</code> dict</p>