{
"chats": {
"3q7QDEHAVpU3DhiNyAOKlZY7L0S25rAQ6mD63HRiygVytCutjMfyZr43": {
"messages": {
"-MhP9vpwRKLND9tIBBOT": {
"message": "thanks",
"senderId": "5rAQ6mD63HRiygVytCutjMfyZr43",
"timeStamp": 1629305419888
},
"-MhSZ8z1kObr2W0UOdZK": {
"message": "hello",
"senderId": "3q7QDEHAVpU3DhiNyAOKlZY7L0S2",
"timeStamp": 1629362363332
},
}
},
"3q7QDEHAVpU3DhiNyAOKlZY7L0S2Ud9F8Ke4bZTMu9vMf5GF98jnwng2":
{},
"5rAQ6mD63HRiygVytCutjMfyZr433q7QDEHAVpU3DhiNyAOKlZY7L0S2":
{},
}
}
I want to retrieve data from the real time database but due to unnamed nodes I am not able to capture the data. Please help me? When I run the function I getting null in console.log:
Path is correct but snapshot shown null in console: snapshot: null
function selectAllData6() {
var Id1 = this.id;
var Path1 = firebase.database().ref("chats/{senderId}/messages/{receiverId}/message");
Path1.on('value', function(snapshot) {
var message = snapshot.val();
console.log("message: " + message);
console.log("Path1: " + Path1);
console.log("snapshot: " + snapshot.val());
});
}
selectAllData6();