title: Cannot get body-parser to return anything
body: <p>I've read dussins of stackoverflow posts now but I can't get my bodyparser to work. In order to not complicate things I changed to the most simple thing I could imagine, which is the code below and involve just parsing one single route. Can anyone see a problem?</p>
  
  <p>routes/login.js</p>
  
  <pre><code>var express = require('express');
  var router = express.Router();
  var bodyParser = require('body-parser');
  
  router.get('/', (req, res) =&gt; {
          res.send('&lt;form method="POST" action="'+ req.originalUrl +'"&gt;&lt;input type="text" id="personalNumber" autocomplete="off"&gt;&lt;input type="submit" value="Log in"&gt;&lt;/form&gt;');
          res.end();
  });
  
  router.post('/', bodyParser.urlencoded({ extended: false }), (req, res) =&gt; {
          console.log('personal', req.body, req.personalNumber, res.body, req.headers);
          res.send('personal', req.body, req.personalNumber, res.body, JSON.stringify(req.headers));
          res.end();
  });
  
  module.exports = router;
  </code></pre>
  
  <p>server.js simplified</p>
  
  <pre><code>var express = require('express');
  var app = express();
  
  var login = require(__dirname + '/routes/login');
  app.use('/login', login);
  
  app.listen(80, () =&gt; {
          console.log('Listening on port 80');
  });
  </code></pre>
  
  <p>Going to /login, typing anything in the input and submitting (triggering a post to /login) will give use the following console output:</p>
  
  <pre><code>Listening on port 80
  personal {} undefined undefined { host: 'localhost',
    connection: 'keep-alive',
    'content-length': '0',
    pragma: 'no-cache',
    'cache-control': 'no-cache',
    origin: 'http://localhost',
    'upgrade-insecure-requests': '1',
    'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36',
    'content-type': 'application/x-www-form-urlencoded',
    accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
    referer: 'http://localhost/login',
    'accept-encoding': 'gzip, deflate',
    'accept-language': 'en-US,en;q=0.8,sv;q=0.6' }
  </code></pre>
  
  <p>Expected output would be for req.body to contain some information about the data from the form.</p>
  
  <pre><code>req.body = {
      personalNumber: 'inputData'
  };
  </code></pre>