[英]when i use firebase.database().goOnline(); I get an error
this is my code这是我的代码
admin.initializeApp({...});
var db = admin.database();
let ref = db.ref(...);
await ref.once("value",function () {...},);
firebase.database().goOffline();
firebase.database().goOnline();
ref.on("value",function () {...},);
);
when i use firebase.database().goOnline();当我使用 firebase.database().goOnline(); I get an error
我得到一个错误
Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app).
at app
You're mixing two ways of addressing Firebase.您混合使用两种寻址方式 Firebase。
You can access Firebase through:您可以通过以下方式访问 Firebase:
firebase
.firebase
。admin
.admin
。 Now you initialize admin
, but then try to access firebase.database()
.现在您初始化
admin
,然后尝试访问firebase.database()
。 And since you did call admin.initializeApp
that's where the error comes from.并且由于您确实调用
admin.initializeApp
这就是错误的来源。
My guess is that you're looking for admin.database().goOnline()
or db.goOnline()
.我的猜测是您正在寻找
admin.database().goOnline()
或db.goOnline()
。
Also note that there is no reason to toggle goOffline()
/ goOnline()
in the way you do now, and you're typically better off letting Firebase manage that on its own.另请注意,没有理由像现在这样切换
goOffline()
/ goOnline()
,通常最好让 Firebase 自行管理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.