I have a really simple JS code:
var worldRef = firebase.database().ref('something/something1');
var something = new Object();
worldRef.on('child_added', function(snap) {
something.id = snap.key;
something.value = snap.val().value;
});
console.log(something);
It works almost fine - just one key&value from database, but it's something. If I modify it:
console.log(something.id);
Undefined. I've tried with map instead of object, but same. I see everything in map, but when I try to call the getmap(key), it's undefined.
Array-based solution:
var worldRef = firebase.database().ref('something/something1');
var something = [];
worldRef.on('child_added', function(snap) {
something.push ({
id: snap.key,
value: snap.val().value
})
});
console.log(something);

console.log(something);works"? Can you pls show the exact output of thisconsole.logas well as where you call it in your code?