UPDATE: Ich hatte einen Fehler auf meinem HTTP-Anfrage-Endpunkt. Ich hatte die entsprechenden Authentifizierungsoptionen nicht eingestellt, so dass viele dieser Fehler möglicherweise behoben wurden.Node.js Lambda-Funktion "Antwort ist ungültig" Amazon Alexa
Meine Frage ist ähnlich wie ein hier:
jedoch die Lösung auf diese Frage nicht mein Problem nicht lösen. Also mache ich eine HTTP-Anfrage an einen xsjs-Dienst in der Hana-Cloud. Ich erhalte die Fehlermeldung "Antwort ist ungültig". Ich kann nicht sehen warum. Hier ist meine Funktion ist:
// Create a web request and handle the response.
function httpGet(query, callback) {
console.log("/n QUERY: "+ query);
var host = 'datacloudyd070518trial.hanatrial.ondemand.com';
var path = '/LocationInformation/getLocationInfo.xsjs?location=';
var hostname = 'https://' + host + path + query;
var auth = 'user1:D1anafer';
var req = http.request({'hostname': hostname,
'auth': auth
}, (res) => {
var body = '';
res.on('data', (d) => {
body += JSON.stringify(d);
});
res.on('end', function() {
callback(body);
});
});
req.end();
req.on('error', (e) => {
console.error(e);
});
}
Und die Funktion, die es nennt:
'getNewsIntent': function() {
//self = this;
httpGet(location, function (response) {
// Parse the response into a JSON object ready to be formatted.
//var output = JSON.parse(response);
//output = output['change'];
var output = response;
var cardTitle = location;
var cardContent = output;
alexa.emit(':tellWithCard', output, cardTitle, cardContent);
});
},
Danke -Diana