简体   繁体   中英

Why I am not getting uuid id from firebase realtime database in react native app

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());
});

我在 console.log() 上获得的数据

我在 firebase 中的数据

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM