Reputation: 35
var dbImages = firebase.database().ref("images");
dbImages.on("value", function(images){
if(images.exists()){
var imageshtml = "";
images.forEach(function(fetchImages){
console.log("key: " + fetchImages.key);
console.log("title: " + fetchImages.title);
console.log("url: " + fetchImages.url);
});
}
});
Its only showing key value not other value i want to view key value and also the value of key value please help guys
Upvotes: 1
Views: 45
Reputation: 50830
You are using forEach()
and DataSnapshot
of /orders
node where each child node seems to be a category and not the image itself. You'll have to loop over each image of the categories to list them:
firebase.database().ref("images").once("value").then((imagesCategories) => {
if (imagesCategories.exists()) {
var imageshtml = "";
// For each category
imagesCategories.forEach(function(categoryImages) {
// For each category image
categoryImages.forEach(function(image) {
// Append data to imageshtml from here
console.log(image.val().url)
console.log(image.val().title)
})
})
}
});
Upvotes: 1