title: How to wait a request response and return the value?
body: <p>When I use a request module in node.js server, I have some problem such as wait and return.</p>
  
  <p>I would like to receive a "responseObject" value at requestController.</p>
  
  <p>To solve this problem, I have search the best way but I still do not find it.</p>
  
  <p>How can solve this problem?</p>
  
  <p>Thank in advance!! :)</p>
  
  <p>=========================================================================</p>
  
  <pre><code>var requestToServer = require('request');
  
  function getRequest(requestObject) {
  
      var urlInformation = requestObject['urlInformation'];
      var headerInformation = requestObject['headerInformation'];
  
      var jsonObject  = new Object( );
  
      // Creating the dynamic body set
      for(var i = 0; i &lt; headerInformation.length; i++)
          jsonObject[headerInformation[i]['headerName']] = headerInformation[i]['headerValue'];
  
      requestToServer({
          url : urlInformation,
          method : 'GET',
          headers : jsonObject
      }, function(error, response ,body) {
          // todo response controlling
          var responseObject = response.headers;
          responseObject.body = body;
      });
  }
  
  // Controlling the submitted request
  exports.requestController = function(requestObject) {
      var method = requestObject['methodInformation'];
      var resultObject = null;
  
      // Selecting the method
      if(method == "GET")
          resultObject = getRequest(requestObject);
      else if(method =="POST")
          resultObject = postRequest(requestObject);
      else if(method == "PUT")
          resultObject = putRequest(requestObject);
      else if(method == "DELETE")
          resultObject = deleteRequest(requestObject);
  
      console.log(JSON.stringify(resultObject));
  }
  </code></pre>