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

349
Views
javascript array push not working with async function

This is my code:

var records = []
  data.docs.forEach(async (e) => {
    var getRC = await firestore()
      .collection('Users')
      .doc(e.data().driverId)
      .get()
    records.push({ data: e.data(), rc: getRC.data().RC })
    console.log(records) /// works here
  })
  console.log(records) /// returns empty

How can i make async function to work with array.push(). I have read other answers, but as a beginer, I am getting difficult to understand it. please help

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!