gpt4 book ai didi

Firebase 身份验证类型错误 : Cannot read property 'getIdToken' of null

转载 作者:行者123 更新时间:2023-12-03 06:31:11 24 4
gpt4 key购买 nike

我正在尝试使用

获取用户 token
import { auth, database } from "firebase";

await token = await auth().currentUser.getIdToken();

但是,我收到了这个错误,

TypeError: Cannot read property 'getIdToken' of null

它有时有效,但有时无效。我在这里做错了什么?

最佳答案

  firebase.auth().onAuthStateChanged(function(user) {
if (user) {
user.getIdToken().then(function(data) {
console.log(data)
});
}
});

关于Firebase 身份验证类型错误 : Cannot read property 'getIdToken' of null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46636907/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com