I'm currently calling an RDS DB to get a list of items, then I loop through these items to then make a POST call for each item. My question is:
Is it possible to loop through this list and call another Lambda function for each item in list. Ideally, this would not wait for a response but would continue calling the others. Each method called would continue running till they are completed. Please note this is based on NodeJs 6.10
Here is the structure:
var pg = require('knex')({ client: 'pg', connection: process.env.DATABASE_URL, debug: true }); // Internal const time = require('./lib/time'); const response = require('./lib/response'); const helpers = require('./lib/helpers'); module.exports.createBatch = (event, context, cb) => { // Lambda settings context.callbackWaitsForEmptyEventLoop = false; const now = time.getCurrentTime(); pg('table') .join('table') .select('*') .then(function(rows) { return rows; }) .then(function(rows) { console.log( 'rows: '+ rows ); let count = 0; if (!_.isEmpty(rows)) { for(let row of rows) { // **** // CALL OTHER LAMBDA FUNCTION HERE // **** axios.post(row) .then(function (res) { // **** // MOVE THIS POST CALL INTO ANOTHER LAMBDA FUNCTION // **** }) } } })