I'm using an async function to get data from a collection in firebase:`
let teste = async function getDados(db)
{
const snapshot = await db.collection('place').doc('House').collection('user').get();
snapshot.forEach((key) => {
console.log(key.id, '=>', key.data());
});
return snapshot
}
console.log("test", teste)
however, when displaying the variable, the result is:
test [AsyncFunction: getDados]
How do I save the result that is displayed in the console.log in the function, in a variable?
Thank you! The final code:
async function getDados(db)
{
const snapshot = await db.collection('place').doc('House').collection('user').get();
let results = [];
snapshot.forEach((key) => {
results.push(key.id, key.data());
console.log(key.id, '=>', key.data());
});
return results
}
async function teste2()
{
let teste = await getDados(db);
console.log("test", teste);
}
teste2();