I am struggling to get data out of the Firestore Cloud. The problem is that I have a function and inside it I have the data from the database, but I can't get it out of the function. I'll attach the code below.
function logBook(doc){
let names = doc.data().name;
console.log(names);
}
db.collection('flights').get().then((snapshot) =>{
snapshot.docs.forEach(doc => {
logBook(doc);
});
})
console.log(names);
Console output: https://prnt.sc/1bgrice
Thanks!