title: req.body is empty express js
body: <p>I have been spending hours trying to figure out why req.body is empty. I have looked everywhere on stackoverflow and tried everything but no luck.</p>
  
  <ul>
  <li><p><a href="https://stackoverflow.com/questions/38294730/express-js-post-req-body-empty">Express.js POST req.body empty</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/47575177/express-req-body-is-empty-in-form-submission">Express req.body is empty in form submission</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/33695893/express-postman-req-body-is-empty/33696105">Express + Postman, req.body is empty</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/43227729/express-js-req-body-returns-empty">Express js req.body returns empty</a></p></li>
  </ul>
  
  <p>I tried setting:</p>
  
  <pre><code>app.use(bodyParser.urlencoded({extended: false})); //false
  </code></pre>
  
  <p>but it did not change anything</p>
  
  <p>Here is app.js</p>
  
  <pre><code>var express = require('express');
  var path = require('path');
  var favicon = require('serve-favicon');
  var logger = require('morgan');
  var cookieParser = require('cookie-parser');
  var bodyParser = require('body-parser');
  
  var index = require('./routes/index');
  var ajax = require('./routes/ajax');
  
  
  var app = express();
  
  // view engine setup
  app.set('views', path.join(__dirname, 'views'));
  app.set('view engine', 'hbs');
  
  // uncomment after placing your favicon in /public
  //app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
  app.use(logger('dev'));
  app.use(bodyParser.urlencoded({extended: true}));
  app.use(cookieParser());
  app.use(express.static(path.join(__dirname, 'public')));
  app.use(bodyParser.json());
  app.disable('etag'); //disable cache control
  
  app.use('/', index);
  app.use('/ajax', ajax);
  
  
  // catch 404 and forward to error handler
  app.use(function (req, res, next) {
      var err = new Error('Not Found');
      err.status = 404;
      next(err);
  });
  
  // error handler
  app.use(function (err, req, res, next) {
      // set locals, only providing error in development
      res.locals.message = err.message;
      res.locals.error = req.app.get('env') === 'development' ? err : {};
  
      // render the error page
      res.status(err.status || 500);
      res.render('error');
  });
  
  module.exports = app;
  </code></pre>
  
  <p>Now let's have a look at ajax.js</p>
  
  <pre><code>var express = require('express');
  var router = express.Router();
  router.post('/1/kyc/form', function (req, res, next) {
      console.log(req.body) //prints {}
  });
  </code></pre>
  
  <p>This is the request done by the client:</p>
  
  <p><a href="https://i.stack.imgur.com/tIaL9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tIaL9.png" alt="enter image description here"></a></p>