我目前正在进行API调用(在纯javascript中)以从外部服务器获取数据。我是一种新的API调用,我现在卡住了。问题是我要求的文件非常大而且调用需要永远。
所以我想知道是否有办法让我一次只能获得5万行或类似的东西。只是为了让它发挥作用。
以下是API:
loadLibrary("cus:json3.js");
var buffer = new MemoryBuffer();
buffer.fromString("username:password", "utf-8");
var http = new HttpClientRequest();
http.header["Authorization"] = "Basic " + buffer.toBase64();
this.baseURL = "https://url...";
http.url = this.baseURL;
http.method = "GET";
http.execute();
var res = String(http.response.body);
var lines = res.split("\r");
var c = 0;
for each (var line in lines) {
if (c == 100) {
try {
var json = JSON.parse(line);
logInfo( "Address: " + json.Address + " id: " + json.id);
}
catch(e) { logInfo(e); }
}
c++;
}
logInfo(c);