firebase display all users on web page

469 views
Skip to first unread message

Pisco faye

unread,
Jan 7, 2017, 11:32:58 AM1/7/17
to Firebase Google Group
hello i use firebase database and i want to display all users on a web page. how can i try this ?

Pisco faye

unread,
Jan 9, 2017, 10:41:10 AM1/9/17
to Firebase Google Group
i use this code to display my users with name :

 var nobject=dbobject.on('value', snap => { dbobject.on('value', function(snap){

        snap.forEach(function(childSnap){
            var key = childSnap.key;//on recupere la clé
            var user = childSnap.val();// on recuper le contenu de
            var username = user.username;//on recup le user
            var photo=user.profile_picture;
          


       
        var msgTextid = document.createElement("i");
        //var keyusertext = document.createElement('p');
        var mybr=document.createElement("br");
        msgTextid.textContent = username;
        //keyusertext.textContent= key;

  
        var msgElement = document.createElement('a');
            //msgElement.href = username;
            //nomuserclicker=key;
            msgElement.onclick = affichagemesguser(username);
        msgElement.appendChild(photoimg);
        msgElement.appendChild(msgTextid);//on affiche l'user
        msgElement.appendChild(mybr);//on va à la ligne
       // msgElement.appendChild(keyusertext);//on affiche l'id
        document.getElementById("listenom").appendChild(msgElement);
            //console.log("user", username);
            //affichertableau();
        });//fin fonction pour afficher les users

     

  });

Kato Richardson

unread,
Jan 9, 2017, 12:24:39 PM1/9/17
to Firebase Google Group

Hello Pisco,

What you have here is close, but you shouldn’t be calling dbobject.on('value') twice (it gets called again inside the callback for the first invocation). And since these are realtime data streams, you probably want to work with child_added instead of value anyway.

Reading data from a list is covered here. Check out that doc and our samples for some pointers.

☼, Kato


--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/7063bfd1-75da-46da-9e53-0b5395bb1597%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Reply all
Reply to author
Forward
0 new messages