javascript - firebase auth is not a function - Stack Overflow

I got this TypeError: WEBPACK_IMPORTED_MODULE_4__firebase.c.auth is not a functionThe line i got an err

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);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744747933a4591417.html

相关推荐

  • javascript - firebase auth is not a function - Stack Overflow

    I got this TypeError: WEBPACK_IMPORTED_MODULE_4__firebase.c.auth is not a functionThe line i got an err

    22小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信