[英]Pulling data from private API using xmlhttprequest
我需要一些帮助,以尝试从私有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.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);
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.