0

I have a value called imgFolder. but I cannot access imgFolder inside getDownloadURL promise. is there a way to access imgFolder inside getDownloadURL(itemRef)... ?

useEffect(() => {
        imgFolderRef.forEach((imgFolder) => {
            const imgRef = ref(storage, imgFolder);
            listAll(imgRef)
            .then((res) => {
                res.items.forEach((itemRef) => {
                    // All the items under listRef.
                    getDownloadURL(itemRef).then(downloadURL => {
                        setImages(oldOne => [...oldOne, { 
                            imgFolder: [downloadURL] 
                        }])
                    })
                });
            })
        })
    }, [imgFolderRef]);
Ozan Bilgiç
  • 215
  • 1
  • 9
  • Hi, can you please elaborate more on your question? What do you mean by this: `and when I write imgFolder inside setImages it shows me imgFolder, but I don't want this`? – Michael Boñon Jan 21 '22 at 16:05
  • when I write, " imgFolder: [downloadURL] ", this, I get result of imgFolder: value, but on the top, const imgRef = ref(storage, imgFolder); , here I already have a imgFolder value. so when I write imgFolder: [downloadURL] this thing. I want to get imgFolderValue : [downloadURL]Value. I hope this can be clear – Ozan Bilgiç Jan 21 '22 at 16:09
  • I found the solution here: https://stackoverflow.com/questions/2274242/how-to-use-a-variable-for-a-key-in-a-javascript-object-literal – Ozan Bilgiç Jan 21 '22 at 16:51

0 Answers0