title: How to get body from a post request in Nodejs?
body: <p>I am sending data <code>id</code> using post method to my node server. But <code>req.body</code> is undefined in my node file</p>
  
  <p>My index.html looks like this:</p>
  
  <pre><code>&lt;html ng-app="IMDBApp"&gt;
  &lt;body&gt;
      &lt;div ng-controller="testController as movieFetcher" class="container"&gt;
          &lt;input type="text" ng-model="movieFetcher.movieId"&gt;&lt;/input&gt;
          &lt;button ng-click="movieFetcher.sendId(movieFetcher.movieId)"&gt;Fetch Details&lt;/button&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>My Angular Controller looks like this:</p>
  
  <pre><code>angular.module('testApp', []).controller('testController',['$http',function($http){
  this.movieId = 197;
  this.sendId = function(id){
      $http.post('/test',id).success(function(response){
       // does something on response
      });
  }; }]);
  </code></pre>
  
  <p>My node server looks like :</p>
  
  <pre><code>var express = require('express');
  var app = express();
  var bodyParser = require('body-parser');
  app.use(express.static(__dirname + '/public'));
  app.use(bodyParser.text());
  app.listen(8080);
  
  
  app.post('/test', function(req, res) {
   var i = req.body;
   var url = 'http://www.imdb.com/title/tt' + i + '/';
   // i shows as undefined
   console.log("i is",i,"url is",url);
   res.send(url);
  });
  </code></pre>