I want to get each file's name from firebase storage and put in map array, so I got this code.
listRef.listAll().then((res) => {
    res.items.forEach((itemRef) => { 
      //console.log(itemRef);
      
      itemRef.getMetadata().then((metadata) => {
        itemName = metadata.name;
        map.set(i,itemName);
        i++;
      
      }).catch((error) => {
        console.log(error);
      });
    });
  }).catch((error) => {
    console.log(error);
  });
  console.log(map); //it shows Map(0) but have entries in it
  map.forEach((value,key) => {
    console.log("123") //nothing happened
});
I successfully got names all in the map, but it shows Map(0) and have those names in its entries... so I can't get anything in forEach cycle, do anyone know why does it occur and how to solve it?
