title: How do I get input POST data in Node.js?
body: <p>I am learning Node.js. I am trying to learn it without using 3rd party modules or frameworks.</p>
  
  <p>I am trying to figure out how I can get the POST data from each individual input.</p>
  
  <p>I am making a login system:</p>
  
  <pre><code>&lt;form method="POST" action="/login"&gt;
     &lt;input name="email" placeholder="Email Address" /&gt;
     &lt;input name="password" placeholder="Password" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>So the user logins and the input data is <strong>POST</strong>ed to the server.</p>
  
  <p>The Node.js server is ready for this POST :</p>
  
  <pre><code> var http = require('http');
   var server = http.createServer(function(req, res) {
  
  
   if(req.method == POST &amp;&amp; req.url == '/login') {
  
  
   var body = "";
  
   req.on('data', function (chunk) {
   body += chunk;
    });
  
  
   req.on('end', function () {
   console.log(body);
   });
  
   }
  
   });
   server.listen(80);
  </code></pre>
  
  <p>The node.js server code above can console.log the body. For example, this will console.log the post data like this:<br>
         <em>email=emailaddy@gmail.com password=thisismypw</em></p>
  
  <p><strong>BUT how do I get the input data individually?</strong> I think in PHP I could target each input this way:</p>
  
  <pre><code>  $_POST['email']  and $_POST['password']
  </code></pre>
  
  <p>and I could put these values into a variable and use them to INSERT or CHECK the database.</p>
  
  <p>Can someone please show me how I can do this in Node.js? Please no modules barebones please!</p>