私が作成しようとしているアレクサのスキルは、私が作成したAPIを読み込みます。 APIが正常に動作してラムダを使用してAlexaスキルからnullレスポンスを取得
{
"_id": "5a4523104494060cf097c1ad",
"description": "Sprinting",
"date": "2017-12-29"
}
を返して、私は次のコード
そのままコンソール出力2017-12-29T09:33:47.493Z dThe session will be
2017-12-29T09:33:47.951Z aThe session will be
2017-12-29T09:33:47.952Z c The session will be
2017-12-29T09:33:48.011Z bThe session will beSprinting
は、しかし、これはthis.emit機能のためにnullを返している
'getNext': function() {
var url = '***API ADDRESS*** ';
var text = "The session will be";
https.get(url, function(response) {
var body = '';
response.on('data', function(x) {
body += x;
});
console.log("a" + text);
response.on('end', function() {
var json = JSON.parse(body);
text += json.description;
console.log("b" + text);
this.emit(":tell", text);
});
console.log("c " + text);
});
console.log("d" + text);
// this.emit(":tell", text);
}
を持っています。
私はそれをコメントし、他のコメントを外すと <speak> The session will be</speak>
が返されます。
私はスコープとは関係がありますが、なぜテキストがログbで正しいのですが、dでは正しくないと思うと思います。もし、私がこの共鳴音でこのエミットを使うことができなければ、最後に使用する情報をそこから得る方法が必要です。