title: How to return a node stream request data in a method?
body: <p>I have sample code as following.</p>
  
  <pre><code>var getPostedData =  function (request) {
      var qs = require('querystring');
      var body = '';
      request.on('data', function(chunk) {
          body += chunk.toString();
      });     
      return qs.parse(body);
  };
  getPostedData();
  </code></pre>
  
  <p>But the connection request data is coming as stream or multiple data packets. It cannot be returned as like above code in node <strong>v0.12</strong>. The sample code will work with node <strong>v0.10</strong>. </p>
  
  <p>One solution to multiple data packets is to listen <code>end</code> event emit on request object.</p>
  
  <pre><code>var getPostedData =  function (request) {
          var qs = require('querystring');
          var body = '';
          request.on('data', function(chunk) {
              body += chunk.toString();
          }).on('end', function() {
              //Here body will have multiple data packets
              //return qs.parse(body);
          });     
          return qs.parse(body);
      };
      getPostedData();
  </code></pre>
  
  <p>But here we can't get return value because of asynchronous nature. 
  How to return full multiple data chunks in a function/method?</p>