This is my code to fetch data from firebase:
const querySnapshot = await db.collection('entries').get()
I want to add the data of every entry-element to a new array for which I got two ways to do it:
querySnapshot.forEach((entry) => {
const entryData = entry.data()
entries.value.push(entryData)
})
and
for (const entry of querySnapshot) {
const entryData = entry.data()
if (entry) { entries.value.push(entryData)
}
The first solution works, but the second throws this error: TypeError: "querySnapshot is not iterable". Aren't the two ways basically doing the same? Why does on throw an error while the other doesn't?