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?