Friday, 12 May 2017

Firebase in node.js not working

I am facing some issues to implement firebase in node. Below is the code I am trying to run on node.

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

var serviceAccount = require("./service_account.json");

admin.initializeApp({
     credential: admin.credential.cert(serviceAccount),
     databaseURL: "https://<myfirebasedb>.firebaseio.com/"
});

var Queue = require('firebase-queue')

firebase.initializeApp({
    databaseURL: "https://<myfirebasedb>.firebaseio.com/"
});

//start your worker here. "users" is a table in my db which has users.
var ref = firebase.database().ref('users');
var queue = new Queue(ref, function(data, progress, resolve, reject) {
  // Read and process task data
  console.log(" Inside I am!! ")
  console.log(data);

  // Do some work
  progress(50);

  // Finish the task asynchronously
  setTimeout(function() {
    resolve();
  }, 1000);
});

console.log(" hello world ")

Seems my code never runs. It only prints the "hello world" which is the last line.



via TechBee

No comments:

Post a Comment