Noejs obtains remote json data

  • content
  • comment
  • relevant

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"); // If it is a resource type, it needs to be set to binary
res.on("data", function(chunk){
json+=chunk;
});

res.on("end", function(){
console.log(json)
});
});

comment

zero Comments

Post reply

Your email address will not be disclosed. Required items have been used * tagging