林试图检索从火力DB用户,但是当我打印snapshot.val()它显示[对象的对象。我怎样才能打印真实的数据?谢谢!火力地堡snapshot.val()返回的翻译:
FriendlyChat.prototype.getRandomInterlocutor = async function(){
var numberOfUsers = await this.getNumberOfUsersRef();
var randomIndex = Math.floor(Math.random() * numberOfUsers);
if(randomIndex == 0){
randomIndex = 1;
}
var ref = await firebase.database().ref('companies/' + this.company + '/users/');
ref.limitToFirst(randomIndex).once('value').then(snapshot =>
{
var user = snapshot.val();
console.log('getRandomInterlocutor = ' + user);
return user;
});
}
FriendlyChat.prototype.onAuthStateChanged = function(user) {
console.log('entro a onAuthStateChanged');
this.interlocutor = this.getRandomInterlocutor();
console.log(this.interlocutor);
}
just console.log(user)找到用户对象的结构。 – error404