I load an array of documents using an async function. If I print in the console the array.length this value result 0, but if I print the array I can see all the values, and they seems correctly loaded.
const array = [];
async function getArray() {
const arraySnaps = await getDocs(collection(db, "CollectionName"));
for(var i = 0; i < arraySnaps.docs.length; i++){
arrayList[i] = arraySnaps.docs[i].data();
}
return array;
}
getArray();
console.log(array.length);
console.log(array);
This is a problem because I can not use the values in other parts of code, because the array result empty.
If you need I can also post the two logs.