Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

代码如下:
var http = require("http");

var options = {

// host: 'api.81p.net/api?p=json&t=jisupk10&token=15414985AABD5796&limit=1'
host: 'api.81p.net',
path: '/api?p=json&t=jisupk10&token=15414985AABD5796&limit=1'

};

http.get(options, function (http_res) {

// initialize the container for our data
var data = "";

// this event fires many times, each time collecting another piece of the response
http_res.on("data", function (chunk) {
    // append this chunk to our growing `data` var
    data += chunk;
});

// this event fires *one* time, after all the `data` events/chunks have been gathered
http_res.on("end", function () {
    // you can use res.send instead of console.log to output via express
    console.log(data);
});

});
为什么会报错呢???,报错如下:
image.png
请问怎么样获得这个接口的数据呢???
http://api.81p.net/api?p=json...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

错误信息提示,你本地无法解析这个域名,你本地 ping 下这个域名,能拿到 ip 吗?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...