我在 AWS Lambda 控制台上有我的 Alexa 的 lambda 函数。在那里我调用了我创建的 Web API。
如果我在 Visual Studio Code 上调用我的 Web API,效果很好。但是如果我使用 Alexa Developer Console 来调用我的 Web API,它总是说:
错误:连接 ECONNREFUSED 127.0.0.1:63713
这是因为我的 Web API 在localhost? 我该如何解决这个问题?我还在努力使用 Alexa Developer Console 在本地进行测试......
我的代码:
var url = "http://localhost:63713/_apis/v1.0/Car/GetCarById?id=1";
http.get(url, function (res) {
var webResponseString = '';
if (res.statusCode != 200) {
doWebRequestCallBack(new Error("Non 200 Response"), null);
}
res.on('data', function (data) {
webResponseString += data;
});
res.on('end', function () {
var webResponseObject = JSON.parse(webResponseString);
doWebRequestCallBack(null, webResponseObject);
});
}).on('error', function (e) {
doWebRequestCallBack(new Error(e.message), null); // <-- where I recive the error message
});