Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138163

Resolve promises in iteration

$
0
0

I'm looking to iterate over a number of promises but the lambda function is completing before they are resolved.

module.exports.handler= async(event, context, callback) => {
  let a = {'a': 'b', 'x', 'y'};
  let b = {'i': 'n'};

  Object.keys(listA).map(async ax => {
    Object.keys(listB).map(async bx => {
      await validate(ax, bx);
    }
  }
}

async function validate(a, b) {
  let promise = getPromise(a, b);
  await promise.then((output) => {
    ...
    console.log('success');
  });
}

How can all the promises be resolved before the process completes?


Viewing all articles
Browse latest Browse all 138163

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>