Thursday 20 April 2017

How do I retrieve firebase data in web

So, All I need to do is to count the total user data.

I tried this code:

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

admin.initializeApp({
  credential: admin.credential.cert({
    projectId: "",
    clientEmail: "",
    privateKey: ""
  }),  
  databaseURL: ""
});

var db = admin.database();
var ref = db.ref();

ref.once("value", function(snapshot) {
  console.log(snapshot.numChildren());
});

This code works in firebase-admin which I am using NodeJS, but I when I want to retrieve total data in the normal javascript. It doesn't work.

No, I dont try this NodeJS code in the web. I tried the javascript one. But it doesn't work.



via Andre Christoga

No comments:

Post a Comment