javascript - 如何安全地访问 firebase 数据以自动填充网页?
问题描述
当用户进入事件页面时,我希望 JS 自动从 FIREBASE 检索数据并填充 HTML(无需用户登录)。我在发布的代码中使用了“signInAnonymously”函数。它似乎有效,但我如何也自动注销???我想要做的甚至可能吗?我尝试在各个地方使用 firebase.auth().signOut() 无济于事。
(function () {
// Initialize Firebase
var config = {
apiKey: "xxxx",
authDomain: "xxxx.firebaseapp.com",
databaseURL: "https://xxxxx.firebaseio.com",
projectId: "xxxxxxx",
storageBucket: "xxxxxxx.appspot.com",
messagingSenderId: "xxxxxxxxxxx"
};
firebase.initializeApp(config);
firebase.auth().signInAnonymously();
let database = firebase.database();
let ref = database.ref('events');
// Query DB - init UI once
ref.once('value', getDBData, DBerror);
// Data parsing and DOM manipulation code follows here but no issues with that part........
}());
解决方案
推荐阅读
- multi-tenant - 使用 AWS Timestream 和 Appsync 实现多租户
- c# - 如何替换stringbuilder中的最后一行
- php - 如何将字符串中的数字替换为相应的图像名称、标题、描述
- javascript - 如何在下降时将实时值颜色更改为绿色,下降时更改为红色?
- php - 在 php 表中显示 YES 或 NO 而不是 1 和 0
- python - 导入quandl数据查询
- java - 如何对字母表添加值进行简单的加密?
- python - 如何将变量赋予具有默认值的python函数
- javascript - javascript onclick表单功能
- tinymce - 如何在突出显示部分自定义与文本颜色不同的颜色?