I am working on lambda function using node js. I calling a function which return a promise on then I am calling a promiseAll. My first function gets a row form DB based on ID, if row is not present I want to return error response and if present it should call promiseAll.
Following is my code:
return getDetailsOfRow(id).then(function() { return Promise.all([ getDetailsOfA(query1), getDetailsOfB(query2), getDetailsOfC(tripLocationsQuery) ]).then(function(values) { return combineResults(); }) }); function getDetailsOfRow(trip) { return new Promise((resolve, reject) => { con.query(query, id, (err, results, fields) => { if (err) { reject(err); } if (results.length < 1) { createErrorResponse(); } else { //get the set column values to use for other function } }); }); } function createErrorResponse() { return new Promise((resolve, reject) => { var response = { "isBase64Encoded": false, "statusCode": 404, "headers": { "Content-Type": "text/html" }, "body": "Invalid Key" }; resolve(response); }); } promise inside createErrorResponse method is not getting called for lambda function. I am not getting any response from a lambda function. I didn't find any solution. Is it because I will br returning a promise inside a promise if call createErrorResponse() from getDetailsOfRow() ?