It's easy to get value:
firebase_instance.limit(100).on("child_added", function(data) {
var value = data.val();
});
but how to get a key associated with that value?
Use key property
firebase_instance.limit(100).on("child_added", function(snap) {
var name = snap.key;
});
Documentation and examples here
Each of your Firebase .on(...)
callbacks are going to be invoked with a Firebase DataSnapshot. To get the name for the location of that DataSnapshot, try using the name() method.
For example:
firebase_instance.limit(100).on("child_added", function(snap) {
var name = snap.name();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With