I am able to set the UUID id and messages in the firebase database but when I am trying to get UUID from firebase I am not able to get that UUID. If you have any idea then please help me i am new in firebase
const chatRoomRef = database().ref(firebaseMessages.CHAT_ROOM);
chatRoomRef.once('value').then(snapshot => {
console.log('User data: ', snapshot.val());
});
From what I understand you are trying to access the keys (UUIDs) of the children dataSnapshots
of the parent dataSnapshot
.
If this is what you want to do, then try like this:
const chatRoomRef = database().ref(firebaseMessages.CHAT_ROOM);
chatRoomRef.once('value').then(snapshot => {
//loop through the children here
snapshot.forEach((child) => {
//print the key or UUID of each child
console.log('User data: ', child.key);
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.