我需要一些帮助来尝试从私有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状态但是未定义的响应。
对于我的生活,我不能弄清楚如何提取任何特定数据或任何数据。任何帮助将不胜感激。
答案 0 :(得分:0)
这可能会有所帮助......
xhr.onreadystatechange = function () {
if (xhr.readyState < 4)
console.log("Loading...");
else if (xhr.readyState === 4) {
if (xhr.status == 200 && xhr.status < 300)
{
console.log(xhr.responseText);
}
}
}