I have my Alexa's lambda function on AWS Lambda Console. There I call a web API I created.
If I call my web API on Visual Studio Code, it works great. But if I use Alexa Developer Console to call my web API, it always says:
Error: connect ECONNREFUSED 127.0.0.1:63713
It's because my web API is in localhost
? How can I solve this? I'm struggling yet to testing in local with Alexa Developer Console...
My code:
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
});