I followed all the steps for the server configuration in https://firebase.google.com/docs/database/server/retrieve-data#section-start, but when I try to create the reference in the browser tells me that the application called [default] already exists. At that time if preiono F5 then tells me that there is "databaseUrl" I must make sure to provide that data when starting the application firebase.
var express = require('express');
var router = express.Router();
var firebase = require('firebase');
/* GET home page. */
router.get('/', function(req, res, next) {
firebase.initializeApp({
serviceAccount: "aaaabbbbcccc.json",
databaseUrl: "https://xxxxxyyyyyzzzzz.firebaseio.com/" // <<<<--- it can not find
});
var db = firebase.database(); // <<<<---- Here is a problem
var ref = db.ref('vistas/principal');
ref.once('value', function(data){
res.render('index', { title: 'Express' });
});
});
module.exports = router;
I created other authorizations, other keys, etc. But nothing works. Thank you.
Node -v = v4.2.6 Firebase v3.x
FIREBASE FATAL ERROR: Can't determine Firebase Database URL. Be sure to include databaseURL option when calling firebase.intializeApp().
Error: FIREBASE FATAL ERROR: Can't determine Firebase Database URL. Be sure to include databaseURL option when calling firebase.intializeApp().
at Error (native)
at ad (c:\TsPrj\_pruebas\vistas-realtime-desde-firebase\node_modules\firebase\database-node.js:37:278)
at Object.firebase.INTERNAL.registerService.Reference [as database] (c:\TsPrj\_pruebas\vistas-realtime-desde-firebase\node_modules\firebase\database-node.js:238:113)
at O.u (c:\TsPrj\_pruebas\vistas-realtime-desde-firebase\node_modules\firebase\app-node.js:16:94)
at Object.d [as database] (c:\TsPrj\_pruebas\vistas-realtime-desde-firebase\node_modules\firebase\app-node.js:18:182)
at c:\TsPrj\_pruebas\vistas-realtime-desde-firebase\routes\index.js:14:21
at Layer.handle [as handle_request] (c:\TsPrj\_pruebas\vistas-realtime-desde-firebase\node_modules\express\lib\router\layer.js:95:5)
at next (c:\TsPrj\_pruebas\vistas-realtime-desde-firebase\node_modules\express\lib\router\route.js:131:13)
at Route.dispatch (c:\TsPrj\_pruebas\vistas-realtime-desde-firebase\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (c:\TsPrj\_pruebas\vistas-realtime-desde-firebase\node_modules\express\lib\router\layer.js:95:5)