I want to display the list of all the files and their download URLs from Firebase using React JS. But I can't do so because there are two separate functions for listing(listAll())
and getting the URLs (getDownloadUrl()
).
storageRef.listAll().then( res => {
const download = []
res.items.forEach( down => {
down.getDownloadURL().then( url => {
// res.items.forEach( item => {
download.push(url);
// console.log(url)
})
this.setState({ download: download})
})
})
storageRef.listAll().then( res => {
const listItem= []
res.items.forEach( item=> {
// res.items.forEach( item => {
itemList.push(url);
})
this.setState({ itemList: itemList})
})
})