I want to get some documents from Firestore. in my callable cloud function, instead of waiting getting document one by one, await one by one, I use Promise.all so I can get all documents faster, like this
const promises = []
upcomingEventIDs.forEach( upcomingEventIDs => {
const p = db.collection("events")
.where("eventID","==",upcomingEventIDs)
.where("isActive","==",true)
.where("hasBeenApproved","==",true)
.where("isCancelled","==",false)
.get()
promises.push(p)
})
const latestEventDataSnapshot = await Promise.all(promises)
and then I want to loop the document snapshots I just get, and here is the problem
latestEventDataSnapshot.docs.forEach( doc => { // <-- error in this line
})
I have an error
TypeError: Cannot read property 'forEach' of undefined
what is wrong in here ? what should I do to get the documents that I just get from Firestore ?