I want to display images on my homepage using Firebase Storage and Javascript. I can read all references of the Images in a folder, but how can I display it on my homepage?
// Now we get the references of these images
listAll(listRef).then((res) => {
res.items.forEach(function (imageRef) {
// And finally display them
console.log(imageRef);
displayImage(imageRef);
});
}).catch((error) => {
// Handle any errors
console.log("Error 1");
});
function displayImage(imageRef) {
test = imageRef.getDownloadURL();
imageRef.getDownloadURL().then(function (url) {
// TODO: Display the image on the UI
const img = document.getElementById('tierFoto');
img.setAttribute('src', url);
}).catch(function (error) {
// Handle any errors
console.log("Error 2");
});
}}
I always get Error 1 The reference (imageRef) looks like this: enter image description here