I am using Firebase (3.x) in a node.js app. I am trying to get data from my firebase database. I initialized the SDK as the docs indicated, and my security rules are public. I have five "users" under
MYFIREBASEURL.firebaseio.com/users. They are visible on the firebase developer console.
var db = Firebase.database();
var usersRef = db.ref("users");
var numbers = [];
usersRef.on('child_added', function(snapshot) {
numbers.push( snapshot.val() );
console.log( 'Added number ' + snapshot.val() );
});
In the above code snippet, no data is added to the numbers array, even though I have five "users."
However, when I change the code slightly to the following:
var db = Firebase.database();
var usersRef = db.ref("users");
usersRef.push("1234567");
var numbers = [];
usersRef.on('child_added', function(snapshot) {
numbers.push( snapshot.val() );
console.log( 'Added number ' + snapshot.val() );
});
the event listener finds "1234567," but it does not find any of the other five pre-existing users. 1234567 (along with the five other users) are visible on my firebase database in the developer console. What might be the problem? Thanks for your help!