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