javascript - "A network error has occurred" error on emailpassword sign up with Firebase - Stack Overflow

I'm following the setup for emailpassword sign up that Firebase has specified in their official d

I'm following the setup for email/password sign up that Firebase has specified in their official documentation; however, I keep getting "a network error has occurred" error when proceeding with authentication.

Authentication code:

window.onload = function() {
  const config = {
        apiKey: "",
    authDomain: "",
    databaseURL: "",
    storageBucket: "",
    messagingSenderId: ""
  };
  firebase.initializeApp(config);
  const btnSignUp = document.getElementById('btnSignUp');

  btnSignUp.addEventListener('click', function() {
    const inputEmail = document.getElementById('username-input');
    const inputPassword = document.getElementById('password-input');

    const email = inputEmail.value;
    const password = inputPassword.value;
    firebase.auth().createUserWithEmailAndPassword(email,    password).catch(function(error) {
        console.log(error);
    });
  });
};

Console errors:

A network error (such as timeout, interrupted connection or unreachable host) has occurred.

I'm following the setup for email/password sign up that Firebase has specified in their official documentation; however, I keep getting "a network error has occurred" error when proceeding with authentication.

Authentication code:

window.onload = function() {
  const config = {
        apiKey: "",
    authDomain: "",
    databaseURL: "",
    storageBucket: "",
    messagingSenderId: ""
  };
  firebase.initializeApp(config);
  const btnSignUp = document.getElementById('btnSignUp');

  btnSignUp.addEventListener('click', function() {
    const inputEmail = document.getElementById('username-input');
    const inputPassword = document.getElementById('password-input');

    const email = inputEmail.value;
    const password = inputPassword.value;
    firebase.auth().createUserWithEmailAndPassword(email,    password).catch(function(error) {
        console.log(error);
    });
  });
};

Console errors:

A network error (such as timeout, interrupted connection or unreachable host) has occurred.
Share Improve this question edited Nov 17, 2016 at 20:42 Frank van Puffelen 601k85 gold badges890 silver badges860 bronze badges asked Nov 17, 2016 at 18:35 NovoNovo 2012 silver badges9 bronze badges 1
  • Please provide more information on the environment you are using. Can you also check your network log. Is the request going out? That should help explain things. – bojeil Commented Nov 18, 2016 at 20:38
Add a ment  | 

1 Answer 1

Reset to default 6

All set - the problem was the 'type' attribute in the button was not defined and was defaulted to a submit type. By setting type="button", the issue was resolved.

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

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

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

关注微信