我很难通过NodeJS从Firebase检索数据。虽然在代码中可以保存数据,但我无法从数据库中恢复数据。为什么会这样?
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));
})