I want to read all child nodes of a node ( let us say messages) and a json for data is shown below. So should get xyz1, xyz2, xyz3 ....
{
"messages" : {
"-M5eDLlTbnvcXT2kfuYQ" : {
"original" : "xyz1"
},
"-M5eDf8iY2c0emnbiw_R" : {
"original" : "xyz2"
},
"-M5eDl2SZ2dDc8UWd8-4" : {
"original" : "xyz3"
}
}
}
I tried following code
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
admin.initializeApp(functions.config().firebase);
export const repeat = functions.https.onCall(function (data, context) {
console.log(' begin ');
admin.database().ref('messages').once('value').then(
function (snapshot) {
console.log(' snapshotRead ' + snapshot.val().toString());
}
);
console.log(' do further ');
}
);
but gets error 'Promises must be handled appropriately' on firebase deploy for line 'admin.database().ref...'
What is the correct way to read all values ?