title: How to handle POST request in node.js
body: <p>I'm trying to handle a post request being sent to my node.js server.
  JavaScript file with a name server.js displays a form on the browser. I want access to the form values after they are posted to the node.js backend.</p>
  
  <p>The form contains a username, repository, and branch. When the form is submitted I want to display back this data back to the user.</p>
  
  <p>The server.js code:</p>
  
  <pre><code>var http = require('http');
  
  http.createServer(function (request, response) {
  response.writeHead(200, {'Content-Type': 'text/html'});
  response.end('&lt;html&gt;&lt;body&gt;'
      + '&lt;h1&gt;XYZ Repository Commit Monitor&lt;/h1&gt;'
      + '&lt;form method="post" action="." enctype="application/x-www-form-urlencoded"&gt;&lt;fieldset&gt;'
      + '&lt;div&gt;&lt;label for="UserName"&gt;User Name:&lt;/label&gt;&lt;input type="text" id="UserName" name="UserName" /&gt;&lt;/div&gt;'
      + '&lt;div&gt;&lt;label for="Repository"&gt;Repository:&lt;/label&gt;&lt;input type="text" id="Repository" name="Repository" /&gt;&lt;/div&gt;'
      + '&lt;div&gt;&lt;label for="Branch"&gt;Branch:&lt;/label&gt;&lt;input type="text" id="Branch" name="Branch" value="master" /&gt;&lt;/div&gt;'
      + '&lt;div&gt;&lt;input id="ListCommits" type="submit" value="List Commits" /&gt;&lt;/div&gt;'
      + '&lt;/fieldset&gt;&lt;/form&gt;'
      + '&lt;/body&gt;&lt;/html&gt;');
  }).listen(8124);
  
  console.log('Server running at http://127.0.0.1:8124/');
  </code></pre>