noejs 获取远程json数据
var http =require("http")
var server = http.createServer(function(req, res){}).listen(8877);
var url1 = "xxx.com/json"
http.get(url1, function(res){
var json = "";
res.setEncoding("utf8"); //如果是资源类型需要设置为binary
res.on("data", function(chunk){
json+=chunk;
});
res.on("end", function(){
console.log(json)
});
});
发表回复