当用户转到事件页面时,我希望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........
}());