Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
How to return async data from looping over array with for of loop?

I need to use the for-of loop and need to await till all the async requests from looping the inputArray array are done and then return the requests array. How can I make this happen?

const getRequests = async () => {
    const bulkEmails = new BulkEmails();
    const requests = [];
    const inputArray = [];
    for (let input of inputArray) {
        const response = await getAsyncData(input);
        if (response.data) {
            bulkEmails.addEmail(..email); // Email added
            if (bulkEmails.emails.length > 500) {
               // If more than 500 emails in one bulk email object, push object with data to requests array
               requests.push({bulkEmails, data: response.data});
               bulkEmails = [];
            }
        }
    }
    return requests;
}

const requests = await getRequests();
// Loop over all (prepare requests to finally send them
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!