I have the following query to retrieve some data from firestore. However, when trying to push the data into classArray, it is empty. I researched a bit, it might be because I don't have await keyword, but not sure. Btw, the console.log does print the data, it's just not saving it to the array.
let classArray = []
firestore.collection('Classes')
.doc(classType)
.collection(subClass)
.onSnapshot(snapshot => (
snapshot.docs
.map(doc => {
classArray.push(doc.data());
console.log(doc.data());
}))
)
How exactly do I fix this issue?