I have an area of my code where users of a group are stored in an array.(我在代码区域中将组的用户存储在数组中。)
In some cases, I want to gather additional data on the users.(在某些情况下,我想收集有关用户的其他数据。)
Here is what I tried so far:(这是我到目前为止尝试过的:)
async getMembersData(groupUid) {
const members = await this.getMembers(groupUid);
var membersData = {};
Object.keys(members).map((key, i) => {
const member = members[key];
firebase.database().ref(`users/${member.uid}`).once('value', snap => {
membersData[member.uid] = {
'uid': member.uid,
'username': snap.child('username').val(),
'imageUrl': snap.child('imageUrl').val(),
'type': member.type,
};
});
});
return membersData;
}
I have this code working similarly by setting state and using the firebase .on() function, but I need it to work with .once() and returning the object.(我可以通过设置状态并使用firebase .on()函数来使此代码类似地工作,但是我需要它与.once()一起工作并返回对象。)
ask by Robert Berge translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…