【发布时间】:2017-10-02 16:32:56
【问题描述】:
我需要一些帮助来尝试从私有 api 中提取数据。这是我的代码
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
var xhr = new XMLHttpRequest();
xhr.responseType = 'json';
xhr.open("GET", "https://pubgtracker.com/api/profile/pc/silentsushix3?api=bc98fb9b-31be-4df4-ac36-fff4c5230b04", true);
xhr.send();
console.log(xhr.status);
console.log(xhr.response);
当这部分脚本运行时,它会返回 200 状态但未定义的响应。
在我的一生中,我无法弄清楚如何提取任何特定数据,或者根本无法提取任何数据。任何帮助将不胜感激。
【问题讨论】:
-
你没有在监听 xhr 的事件
-
XMLHttpRequest 异步运行,还没有结果,因为您立即检查它。有关此概念的背景信息,请参见 pubgtracker.com/api/profile/pc/…
-
@Andreas 确实! pluralsight.com/guides/front-end-javascript/…
标签: javascript api xmlhttprequest