Is this the appropriate way to call multiple keys on the same endpoint
in Firebase?
Yes, generally this is a good solution to retrieve every group this way.
Does Firebase provide a better way to solve this problem?
I don't think Firebase provides any other function/query that could help in this case.
Anyway, this could be improved saving the ref in a variable and looping on the keys of the object directly. Also, if you just need to retrieve those data once, you should use once()
instead of on()
var groupRef = firebase.database().ref('groups/')
var data = snapshot.val()
for (var groupID in data) {
groupRef.child(data[groupID]).once(...)
}
Another way could be using Firebase's functions for the data snapshots, like forEach
snapshot.forEach(function(childSnapshot) {
groupRef.child(childSnapshot.key).once(...)
})