I try to push an array that I got from firestore, but when I try it's undefined
this is the code
const tmp = [];
const ref = firestore.collection("users").doc(user?.uid);
firestore
.collection("countrys")
.get()
.then((x) => {
x.forEach((y) => {
tmp.push(y.data());
});
});
console.log(tmp); //work
console.log(tmp[0]); //no work
this is the result from the console
as I see it's not same like another array
another array like (3) [{…}, {…}, {…}]
,but my array just show []
can someone explain to me why that's not working? thanks!