Tuesday 16 May 2017

Retrieve data firebase with Node

I'm having difficulty retrieving data from Firebase. Although the server is sending data perfectly, when I try to read the data from the database, there is no return.

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://<URL>.firebaseio.com/'
});



// As an admin, the app has access to read and write all data, regardless of Security Rules

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

ref.update({test:'asadasda'},function(){
    console.log("success!");
});

ref.orderByKey().limitToLast(100).on('child_added', function(snapshot){
    console.log(snapshot.key);
});



via neologika desenvolvimento

No comments:

Post a Comment