【发布时间】:2017-07-07 10:16:04
【问题描述】:
更新:我的 http 请求端点有一个错误。我没有设置适当的身份验证选项,因此修复了很多错误,可能是这个特定的错误。
我的问题类似于这里的一个:
但是,该问题的解决方案并不能解决我的问题。因此,我对 Hana 云中的 xsjs 服务进行了 http 请求调用。我收到“响应无效”错误消息。我不明白为什么。这是我的功能:
// 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);
});
}
以及调用它的函数:
'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);
});
},
谢谢你 -戴安娜
【问题讨论】:
标签: node.js amazon-web-services aws-lambda alexa-skills-kit alexa-skill