'Fetching RealTime Data with Google cloud Function

I Want to fetch some data from firebase Realtime Database. with google cloud function, and store that on realTime database I write google function for getting suppose water data . but when I write code for getting water data i didn't get any data and the code deploy successfully. but when I write my code for a single parent element it work but for all parent element it didn't work. Here is my code can anyone help me with it

exports.testing = functions.https.onRequest((request, response) => {
   var db = admin.database();
    var ref = db.ref("/"); //it does not work like that. If i write ("/parentelement")like this it work for single parent id.
    
    ref.on("child_added", function (snapshot) {
      var water = snapshot.val().water;
      response.send({water})
    
        response.send({ "response_status": 200,
            "response_message": "Machine status fetched successfully",
            "data": snapshot.val().water});
    }, function (errorObject) {
        response.send({ "response_status": 401,
            "response_message": "Unable to fetch machine status",
            "response_error": errorObject });
    });
});


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source