title: Nodejs Express req.body turns up undefined
body: <p>I have tried playing around with the body-parser middleware, no matter what is true or false I get my req.body as undefined. Tries going working with GET instead of POST, still nothing. The form has its name for the attribute. I have been at this for an embarrassing amount of time but I refuse to not fix this. Thx in advance :)</p>
  <p>When I worked with the Get me</p>
  <p>Webserver.js</p>
  <pre><code>var express = require('express');
  const bp = require('body-parser');
  var app = express();
  var fs = require('fs');
  
  app.use(bp.json());
  app.use(bp.urlencoded({extended: true}))
  app.use(express.static('pages'));
  
  
  app.get('/', function(req,res)
  {
      res.sendFile(&quot;pages/index.html&quot;);
      res.end();
  });
  
  
  
  app.get(&quot;/process_get&quot;, function(res,req)
  {
      
      response = {
          first_name:req.body.fname
      };
      console.log(response);
      res.end(JSON.stringify(response));
  });
  
  app.post(&quot;/post_test&quot;, function(req,res)
  {
      console.log(&quot;Got bodyy:&quot;, req.query.url + &quot; &quot; + req.body.url);
      res.sendStatus(200);
  });
  
  
  app.get('*',function(req,res)
  {
      res.sendFile('/404.html', {root: 'pages'});
  });
  
  
  var server = app.listen(5000, function ()
  {
      var host = server.address().address;
      var port = server.address().port;
  
      console.log(&quot;Listing on http://&quot; + host + &quot;:&quot; + port);
  })
  </code></pre>
  <p>My html form</p>
  <pre><code>&lt;form id=&quot;survey&quot; action = &quot;post_test&quot; method = &quot;POST&quot;&gt;
                  &lt;label for=&quot;fname&quot;&gt;First name:&lt;/label&gt;&lt;br&gt;
                  &lt;input type=&quot;text&quot; id=&quot;fname&quot; name=&quot;fname&quot;&gt;&lt;br&gt;
                  &lt;li class=&quot;button&quot;&gt;
                      &lt;input type = &quot;submit&quot; value = &quot;Submit&quot;&gt;
                  &lt;/li&gt;
              &lt;/form&gt;
  </code></pre>