How to retrieve the child/child value in Firebase when the key is unknown

The following code enables me to return all the Expressions of the current user. In this example the following Expressions are shown in the console:

But I am not sure how to list all the titles under Expressions for the current user. The desired outcome should be: KIKKER, CPM2MAN

function f_returnUserDetails(a){
    var key;
    var childData;
    return new Promise(function(resolve, reject) { //return promise
        firebase.database().ref('/users/').orderByChild("uid").equalTo(a).on('value', function (snapshot) {
            snapshot.forEach(function(childSnapshot) {
                key = childSnapshot.key;
                childData = childSnapshot.val();
                resolve([childData, childSnapshot.key]);
            });
        });
    });
};

firebase.auth().onAuthStateChanged(function(user){
    var user = firebase.auth().currentUser;
    var uid = user.uid;
    f_returnUserDetails(uid).then((dbItems) => {
        console.log(dbItems[0].Expressions);
    });
});

Capture1

The missing image from my previous post

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.