最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - firebase auth is not a function - Stack Overflow

programmeradmin0浏览0评论

I got this TypeError: WEBPACK_IMPORTED_MODULE_4__firebase.c.auth is not a function

The line i got an error is the first line.

firebase.auth().createUserWithEmailAndPassword(email, password).then(authUser => {

          // Create a user in your own accessible Firebase Database too
          db.doCreateUser(authUser.user.uid, username, email, gender, coin, followers, followings)
            .then(() => {
              this.setState(() => ({ ...INITIAL_STATE }));
              history.push("/");
            })
            .catch(error => {
              this.setState(updateByPropertyName('error', error));
            });
        })
        .catch(error => {
          this.setState(updateByPropertyName('error', error));
        });
      //To prevent reloading of page after submit
      event.preventDefault();
      <Redirect to="/"/>;
    }

I'm trying to create user with email and password using firebase authentication. Also, i am adding all the info from the input to firebase realtime database. I've searching for an answer and all came out as nothing. Anyone know how to fix??

I got this TypeError: WEBPACK_IMPORTED_MODULE_4__firebase.c.auth is not a function

The line i got an error is the first line.

firebase.auth().createUserWithEmailAndPassword(email, password).then(authUser => {

          // Create a user in your own accessible Firebase Database too
          db.doCreateUser(authUser.user.uid, username, email, gender, coin, followers, followings)
            .then(() => {
              this.setState(() => ({ ...INITIAL_STATE }));
              history.push("/");
            })
            .catch(error => {
              this.setState(updateByPropertyName('error', error));
            });
        })
        .catch(error => {
          this.setState(updateByPropertyName('error', error));
        });
      //To prevent reloading of page after submit
      event.preventDefault();
      <Redirect to="/"/>;
    }

I'm trying to create user with email and password using firebase authentication. Also, i am adding all the info from the input to firebase realtime database. I've searching for an answer and all came out as nothing. Anyone know how to fix??

Share Improve this question asked Jun 18, 2018 at 16:23 LillianLillian 1432 silver badges5 bronze badges 2
  • 1 what version of firebase js sdk are you using, and have you make sure you included auth related js? – William Chong Commented Jun 18, 2018 at 16:56
  • Yes, I did. I think there is some plication here because there is firebase-admin at server.js. This is all I can e out with. – Lillian Commented Jun 23, 2018 at 18:36
Add a ment  | 

3 Answers 3

Reset to default 1

Yes because you have not created an instance of the Google provider.

const provider = new firebase.auth.GoogleAuthProvider();

now your code will execute

firebase
  .auth()
    .signInWithRedirect(provider)
    .then((result) => console.log(result))
    .catch((errors) => console.log(error));

More Info could be found here : firebase - link

Did you import firebase correctly?

import * as firebase from 'firebase';

You have called a firebase method prior to initializing firebase firebase.init(config);

发布评论

评论列表(0)

  1. 暂无评论