Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the value of children in Firebase Javascript?

This is my Firebase Database:

firebase database

I need the URLs of the images that are associated alongside the unique random name generated by the push method. Is there any way I could do that? Also, there must exist a better way of sending data. Please, let me know. Thanks.

imgRef.on('value', function(snapshot) {
console.log(snapshot.val());
});

This is, as expected, returning the entire JSON object. I need the URL.

like image 797
Somanshu Srivastava Avatar asked Dec 22 '16 21:12

Somanshu Srivastava


1 Answers

This is the most basic way to show the list of image URLs:

var rootRef = firebase.database.ref();
var urlRef = rootRef.child("user1/DAA Notes/URL");
urlRef.once("value", function(snapshot) {
  snapshot.forEach(function(child) {
    console.log(child.key+": "+child.val());
  });
});
like image 175
Frank van Puffelen Avatar answered Oct 14 '22 04:10

Frank van Puffelen