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: ''
});
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 ? });
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.'
});
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 ? });
Share Improve this question edited Feb 24, 2018 at 18:32 Frank van Puffelen 600k85 gold badges889 silver badges859 bronze badges asked Feb 24, 2018 at 18:18 ChzDzChzDz 1911 gold badge1 silver badge11 bronze badges1 Answer
Reset to default 11Subscribing 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)
)
})