使用谷歌最近发布的新 firebase 3.0.1。
之前,我们有 Firebase.unauth()
方法 https://www.firebase.com/docs/web/api/firebase/unauth.html
但它是旧 API。我在新 API 中看不到任何相关内容:
https://firebase.google.com/docs/reference/node/index-all
您的解决方案是什么?尝试使用类似的东西:
Object.keys(localStorage).forEach(key => {
if (key.indexOf('firebase') !== -1) {
localStorage.removeItem(key);
}
});
最佳答案
通过回调捕获错误:
firebase.auth().signOut().then(function() {
// Sign-out successful.
}, function(error) {
// An error happened.
});
或者像 Adam 提到的那样使用 .catch。
firebase.auth().signOut()
.then(function() {
// Sign-out successful.
})
.catch(function(error) {
// An error happened
});
如果在异步函数内,则使用 await 和 try...catch
try {
await firebase.auth().signOut();
// signed out
} catch (e){
// an error
}
https://firebase.google.com/docs/auth/web/password-auth#next_steps
谢谢AndréKool方向:-)
关于javascript - 在 Firebase v3.0.1+ 中实现注销的最佳方式?更新后删除 Firebase.unauth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37343309/