I am attempting to add url to defiList, but push() doesn't seem to work. When I print out url, it works, but when I print url, the list comes out as empty. See output for the empty defiList array and elements printed out. Any help would be greatly appreciated!
const listRef = ref(storage, 'data');
let defiList = new Array();
listAll(listRef).then((res) => {
res.prefixes.forEach((folderRef) => {
// You may call listAll() recursively on them.
});
res.items.forEach((itemRef) => {
getDownloadURL(ref(storage, itemRef)).then((url) => {
defiList.push(url);
// --- .push() won't work, but console.log() does
console.log(url);
});
});
}).catch((error) => {
console.log(error);
});