我根据这个例子为 Alexa 创建了一个简单的技能:https : //github.com/alexa/skill-sample-nodejs-fact/blob/en-US/lambda/custom/index.js
现在,我希望脚本在调用GetNewFactIntent时在不同的服务器上记录一些内容。
这就是我想要做的,但有一个问题,这不是http.get回调中应该出现的问题。
'GetNewFactIntent': function () {
//var thisisit = this;
http.get("http://example.com", function(res) {
//console.log("Got response: " + res.statusCode);
const factArr = data;
const factIndex = Math.floor(Math.random() * factArr.length);
const randomFact = factArr[factIndex];
const speechOutput = GET_FACT_MESSAGE + randomFact;
this.response.cardRenderer(SKILL_NAME, randomFact);
this.response.speak(speechOutput);
this.emit(':responseReady');
}).on('error', function(e) {
//console.log("Got error: " + e.message);
});
},
什么这需要与上面这个工作的例子更换?