我尝试使用Firebase functions-samples运行isomorphic react app。 但无法获取firebase数据库并获取错误firebase.database不是函数
const firebase = require('firebase')
// Load the Firebase database module.
require('firebase/database')
// Initialize Firebase using a client-side config.
const firebaseConfig = require('./client/firebase-config.json')
firebase.initializeApp(firebaseConfig)
const getDb = (ref) => firebase.database().ref(ref)
// Error firebase.database is not a function
模块版本:
"firebase": "^4.13.0",
"firebase-admin": "~5.12.0",
"firebase-functions": "^1.0.2",
答案 0 :(得分:0)
适用于firebase-admin
const firebase = require('firebase-admin')
const firebaseConfig = require('./client/firebase-config.json')
firebase.initializeApp(firebaseConfig)
const getDb = (ref) => firebase.database().ref(ref)