I have a set of images in firebase storage which I'd like to display on the page. I have a function in my service where I want to download all the URLs at once. I'm not sure how I can write it so that photoSrcs only exits after all the subscribe functions have run.
I have pasted the code I have below but obviously, photoSrcs is going to be empty.
loadPhotoUrls(photos : Photo[]) : any
{
const photoSrcs = {};
photos.forEach(async (photo, index) => {
const fileRef = this.storage.ref('photo.fileLocation');
fileRef.getDownloadURL().subscribe(url => {
photoSrcs[photo.id] = url;
});
});
return photoSrcs;
}