用户.getIdToken不是一个函数


export const editEmail = async (newEmail) => {
await updateEmail(auth, newEmail);
}; // my code in firebase
try {
setLoading(true);
console.log(newEmail);
await editEmail(newEmail);
Setmessage("update email berhasil");
} catch (e) {
console.log(e);
}
setLoading(false);
};// my code handle submit

错误:

TypeError: user.getIdToken is not a function
at updateEmailOrPassword (account_info.ts:127:1)
at updateEmail (account_info.ts:93:1)
at editEmail (firebase.js:46:1)
at handlerSubmit (editEmail.js:34:1)
at HTMLUnknownElement.callCallback (react-dom.development.js:4163:1)
at Object.invokeGuardedCallbackDev (react-dom.development.js:4212:1)
at invokeGuardedCallback (react-dom.development.js:4276:1)
at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4290:1)
at executeDispatch (react-dom.development.js:9040:1)
at processDispatchQueueItemsInOrder (react-dom.development.js:9071:1)

我想更新我的电子邮件使用服务firebase,即updateEmail。如何解决?

updateEmail方法具有updateEmail(user, email)的签名。

在你当前的代码中,你调用的是updateEmail(auth, email),实际上应该是updateEmail(auth.currentUser, email)

注意:updateEmailupdatePassword操作是敏感的,需要用户最近登录,所以当Firebase拒绝请求时,确保你的代码处理。

相关内容

  • 没有找到相关文章

最新更新