title: nodeJs how to make http post request execute
body: <p>I have narrow down my problem to this,
  I want to send post request to an API server but the post request sent only after the program exits.
  my main.js:</p>
  
  <pre><code>var request = require("request");
  send_post_to_server = function(name, responseCallback, outconfig) {
      var outconfig = outconfig || {...};
      request.post({
          url: 'http://localhost:3000/api/backtest',
          json: outconfig
      }, function optionalCallback(error, response, body) {
          responseCallback(error, response, body);
      });
  }
  
  send_post_to_server ('first post request', my_response_callback);
  send_post_to_server ('second post request', my_response_callback);
  while(true); // with the loop, the server never gets the post requests.
  </code></pre>
  
  <p>If I remove the while loop and the program exits, it dose work and I do get the response to <code>optionalCallback</code> and <code>responseCallback</code>. But with the loop, the server dose not get the request.
  why is that happened? and how can I make the program send the request? some kind of flush?
  to run the program I use:
  <code>node main.js</code> and <code>npm istall request</code> for the request module.</p>