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:
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.
If I remove the while loop and the program exits, it dose work and I do get the response to optionalCallback and responseCallback. 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:
node main.js and npm istall request for the request module.
 
    