I got the following code from here
I've tried this code with variable data being equal to 'test=yes' or with data being equal to {test:'yes'} 
Here is the php script
if(isset($_POST['test'])){ 
   error_log("inside");
   echo "and I'd also like to return this";
};
And here is the nodejs piece of code:
function postToPHP(data, path){
    var httpreq = require('http');
    var querystring = require("querystring");
    var data = querystring.stringify(data);
    var options = {
        host : 'localhost',
        path : 'www' + path, //path is well defined in the actual code
        method : 'POST',
        headers : {
            'Content-Type' : 'application/x-www-form-urlencoded',
            'Content-Length' : data.length
        }
    };
    var buffer = "";
    var reqPost = httpreq.request(options, function(res) {
        res.on('data', function(d) {
            buffer = buffer+data;
        });
        res.on('end', function() {
           return buffer;
        });
    });
    reqPost.write(data);
    reqPost.end();
}
And the call of postToPhp
       //treat message?
        var message = "test=yes";
        //OR
        var message = "{test:'yes'}";
        var buffer = postToPHP(message,"path");
        console.log("buffer from PHP",buffer);
buffer is undefined
Nothing is shown in the error log and I assume something is not working with the code that I can't figure so I hope someone can help me figure this one out.
 
    