[英]how to solve "user.getIdToken() is not a function" error coming from a file I didn't create
So I have a simple project with sveltefire (svelte + firebase).所以我有一个简单的 sveltefire 项目(svelte + firebase)。 I can sign in, I can sign out and I can create an account.
我可以登录,我可以退出,我可以创建一个帐户。 In the component to create an account, I have these lines of code:
在创建帐户的组件中,我有这些代码行:
let ActionCodeSettings = {url: 'https://www.Verify.com/?email=' + email };
await sendEmailVerification(email, ActionCodeSettings).then();
let result = getRedirectResult(auth);
However, I am getting an error from a file called "email.ts".但是,我从名为“email.ts”的文件中收到错误消息。 I did not create this file, but it gives me:
我没有创建这个文件,但它给了我:
uncaught error in promise user.getIdToken() is not a function.
I put the lines to send an email verification before I create the user, since I don't want to have a false user.在我创建用户之前,我把这些行发送一个 email 验证,因为我不想有一个虚假的用户。 and it should be sending it since I just inputted the email.
它应该发送它,因为我刚刚输入了 email。 Is it that the problem?
是不是这个问题? if so, is there a work around?
如果是这样,是否有解决方法?
If you check the documentation of the sendEmailVerification
function it expects a User
object as its first argument, while it seems that you are passing in a email address.如果您查看
sendEmailVerification
function的文档,它期望User
object 作为其第一个参数,而您似乎传递的是 email 地址。
You'll need to pass in a User
object, for example as shown in the documentation on sending a user verification email :您需要传入
User
object,例如发送用户验证 email的文档中所示:
mport { getAuth, sendEmailVerification } from "firebase/auth";
const auth = getAuth();
sendEmailVerification(auth.currentUser)
.then(() => {
// Email verification sent!
// ...
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.