How to get the key from a Firebase data snapshot?

前端 未结 5 1215
南旧
南旧 2021-02-01 02:52

I\'m able to query my users array with an e-mail address and return the user\'s account info:

users.orderByChild(\'email\').equalTo(authData.user.em         


        
5条回答
  •  清酒与你
    2021-02-01 03:29

    I found new way to get the data based on snapshot key -

     firebase.database().ref('events').once('value',(data)=>{
          //console.log(data.toJSON());
          data.forEach(function(snapshot){
            var newPost = snapshot.val();
            console.log("description: " + newPost.description);
            console.log("interest: " + newPost.interest);
            console.log("players: " + newPost.players);
            console.log("uid: " + newPost.uid);
            console.log("when: " + newPost.when);
            console.log("where: " + newPost.where);
          })
          })
    

提交回复
热议问题