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; ?