简体   繁体   中英

Fetching specific data from firebase array

so I have this collection:

I am trying to only get the groupID's in the array there are like 3 of them, but I tried a for loop in a for loop but it keeps returning undefined. Where am I going wrong?

fire.firestore().collection('userEvents2').doc(fire.auth().currentUser.uid).set({
    groups: groupsList
})


for (let i = 0; i < groupsList.length; i++) {
    const key = "";
    for (key in groupsList[i]) {
        console.log(key.groupID)
      }
    
  }

Perhaps the loop is trying to run before groupList is resolved?

Is that the complete code? Are you storing groupList in a variable like let groupList = groups.groupList; ?

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