我正在尝试使用Netflix轮盘API进行API调用,并且我已经控制台记录了响应以确保我正在检索信息(我是)但是,我仍然在控制台中收到此错误:< / p>
Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING
我被告知这可能是因为一些事情:
•防病毒软件
•Google Chrome浏览器设置
•确保所有回复都有response.end()
据我所知,我已经消除了这些原因,但我仍然遇到了这个错误。以下是我打电话的地方:
var EventEmitter = require("events").EventEmitter;
var https = require("https");
var http = require("http");
var util = require("util");
var unirest = require('unirest');
/**
* An EventEmitter to get actor's Netflix info
* @param actor
* @constructor
*/
function Actor(actor) {
EventEmitter.call(this);
actorEmitter = this;
var request = unirest.get("https://community-netflix-roulette.p.mashape.com/api.php?actor=" + actor)
.header("X-Mashape-Key", "DHmuGLtqcomshyLbBKe5akHeFbN1p1UqyGmjsn7uCNpoDXhBXo")
.header("Accept", "application/json")
.end(function(response) {
var body = "";
if (response.statusCode !== 200) {
request.abort();
actorEmitter.emit("error", new Error("There was an error getting titles for " + actor.replace("%20", " ") + ". (" + http.STATUS_CODES[response.statusCode] + ")"));
}
response.on('data', function(chunk) {
body += chunk;
actorEmitter.emit("data", chunk);
});
response.on("end", function() {
if (response.statusCode === 200) {
try {
var actor = JSON.parse(body);
actorEmitter.emit("end", actor);
} catch (error) {
actorEmitter.emit("error", error);
}
}
}).on("error", function(error) {
actorEmitter.emit("error", error);
});
});
}
util.inherits(Actor, EventEmitter);
module.exports = Actor;
如果您需要更多参考,请点击此处链接: