【发布时间】:2017-02-05 22:49:20
【问题描述】:
我目前正在使用 node.js (Alexa SDK),但在发送 get 请求时遇到问题。我的请求如下所示:
http.get("http://graph.facebook.com/v2.7", function(res) {
res.on('data', function (chunk) {
temp += chunk;
});
res.on('end', function () {
//Figure out how to not use "this" keyword because it doesn't work....
this.emit(":ask", toAsk, temp);
});
}).on('error', function (e) {
console.log("Got error: ", e);
});
如您所见,在“结束”回调中,我不能使用标准的“this.emit”,因为“this”指的是该上下文中的其他内容。我对如何解决这个问题有点困惑。有人可以帮忙吗?
谢谢
【问题讨论】:
标签: javascript node.js this