var http = require('http');
var querystring = require('querystring');
var contents = {
'name':'Nemo',
'age':'23',
'address':'beijing'
}
contents = querystring.stringify(contents);
var options = {
'host':'localhost',
'port':'3000',
'method':'POST',
'path':'/',
'headers':{
'Cotent-Type':'application/x-www-form-urlencoded',
'Content-Length':contents.length
}
};
var req = http.request(options,function (res){
res.setEncoding('utf-8');
res.on('data',function (data){
console.log('获取到的后台返回数据');
console.log(data);
});
});
req.write(contents);
req.end();
var querystring = require('querystring');
var contents = {
'name':'Nemo',
'age':'23',
'address':'beijing'
}
contents = querystring.stringify(contents);
var options = {
'host':'localhost',
'port':'3000',
'method':'POST',
'path':'/',
'headers':{
'Cotent-Type':'application/x-www-form-urlencoded',
'Content-Length':contents.length
}
};
var req = http.request(options,function (res){
res.setEncoding('utf-8');
res.on('data',function (data){
console.log('获取到的后台返回数据');
console.log(data);
});
});
req.write(contents);
req.end();