title: Cloud function only retrieving first item in database, not all
body: <p>I have a cloud function working with a Firebase realtime database to retrieve some data. There are several items in my database, however the function is currently only retrieving the first item. I am unsure why this is happening as there is a for loop I am using to iterate over all the items. Here is my code:</p>
  
  <pre><code>admin.initializeApp(firebaseConfig);
  var ref = admin.database().ref('users')
  
  exports.checkusers = functions.https.onRequest((req, res) =&gt; {
      ref.on("value", function(snapshot) {
          snapshot.forEach(function(childSnapshot) {
              let users =  [];
              users.push({
                  key: childSnapshot.key,
                  data: childSnapshot.val()
              })
              return res.json(users);
          });
      })
  })
  </code></pre>
  
  <p>I have tried to fix this but this is the Google style of doing this so I am unsure why this isnt working. Any help will be much appreciated.</p>