0

I earlier had a code with Promise.allSettled(payoutPromises);

But it couldn't work on our server because it has a version 10 for nodejs.

This is what I came up with to do something similar , using some blogs as reference .

  async.each(transactions, function(transaction, iteratorCB) {
    payoutPromises.push(function(callback) {
      ValidationHelper.bankPayoutTransfer(transaction, 'neft').then((data) => {
        response.push({"status":"fulfilled","value":data});
        callback(null, data);
      }).catch((_err) => {
        response.push({"status":"rejected","reason":_err});
      });
    });
    iteratorCB();
  }, function() {
    async.parallel(payoutPromises, function(err, results) {
      console.log(err,results);
    });
  })

The problem I am facing is I want to wait for this async block before executing the rest of the code, like we can using a then after Promise.allSettled I am a noob in terms of nodejs and working on it since a year.

Akshay Hazari
  • 3,186
  • 4
  • 48
  • 84

1 Answers1

1

Posting my comment as an answer:

Try implementing this module. It seems to be pretty popular and it does the thing you want to implement.

Sebastian Kaczmarek
  • 8,120
  • 4
  • 20
  • 38