It is a simple requirement - how do I return the entire json from a firebase database.
My function is as such [index.js]
const functions = require('firebase-functions');
const admin = require('firebase-admin');
var serviceAccount = require('./xxMyKeyxx.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: 'https://xxmyProjectxx.firebaseio.com'
});
exports.myQuery = functions.https.onRequest((req, res) => {
// Grab the text parameter.
const original = req.query.text;
return admin.database().ref('/myFbDatabase').once.xxx
I lost it from here.
what is the syntax to return the Json that is sitting in my FB database /myFbDatabase ? });
Subscribing to the 'value' event will give you the entire database
exports.myQuery = functions.https.onRequest((req, res) => {
// Grab the text parameter.
const original = req.query.text;
admin
.database()
.ref('/myFbDatabase')
.once('value',
snap => res.json(snap.val()),
err => res.json(err)
)
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With