Tuesday, 16 May 2017

NodeJS save data in Firebase but no retrieve data

I'm having difficulty retrieving data from Firebase through NodeJS. Although in the code it is possible to save data, I am not able to recover the data from the database. Why is this happening?

var firebase = require("firebase-admin");

// Fetch the service account key JSON file contents
var serviceAccount = require("./serviceAccountKey.json");

firebase.initializeApp({
  credential: firebase.credential.cert(serviceAccount),
  databaseURL: 'https://<MY URL>.firebaseio.com/'
});

var db = firebase.database();
var ref = db.ref("bd/");

ref.once('value').then(function(snapshot){
    var back=snapshot.exportVal();
    console.log(JSON.stringify(back));
})



via neologika desenvolvimento

No comments:

Post a Comment