Reputation: 2643
Been debugging all night, but I can't figure out why my http request is not being called
return getWordDefinition(queryUrl).then(function(responseMsg) {
//Perform some other business logic
},
function(err) {
console.log('Error Getting Definition: ' + err);
});
The function I'm trying to call:
function getWordDefinition(queryUrl){
const options = {
method: "GET"
};
return new Promise(function(resolve, reject) {
const request = https.request(queryUrl, options, function(response) {
console.log("STATUS CODE: " + response.statusCode); // <------Not being called
var data;
response.on("data", function(chunk) {
if (!data) {
data = chunk;
} else {
data += chunk;
}
});
response.on("end", function() {
console.log("Data: " + JSON.stringify(data));
resolve("Finished getting data");
});
request.on('error', (e) => {
reject("ERROR ON REQUEST: " + e.message);
});
request.end();
});
});
}
This code is inside my AWS lambda function
which seems to be timing out.
I'm logging the status code for the http request, but it's never being called in my function.
What am I doing incorrectly?
Upvotes: 0
Views: 47
Reputation: 78840
Your Lambda is making an HTTP request and it appears to be timing out?
Here are 3 possible reasons, in descending order of likelihood:
See Internet and service access for VPC-connected functions for #1.
Upvotes: 1