简体   繁体   中英

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). 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". 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. and it should be sending it since I just inputted the 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.

You'll need to pass in a User object, for example as shown in the documentation on sending a user verification email :

mport { getAuth, sendEmailVerification } from "firebase/auth";

const auth = getAuth();
sendEmailVerification(auth.currentUser)
  .then(() => {
    // Email verification sent!
    // ...
  });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM