北漂IT民工 的博客

nodejs 下post代码


var options = {

host: ‘www.yourdomain.com’,

post: 80,

method: ‘POST’,

path: ‘/‘,

headers: {

‘Content-Type’: ‘application/x-www-form-urlencoded’,

‘Content-Length’: params.length

}

};

var request = http.request(options, function(response) {

response.setEncoding(‘utf8’);

response.on(‘data’, function(chunk) {

console.log(chunk);

});

});


request.write(params);

request.end();