P
P
p4p2019-09-09 01:58:07
firebase
p4p, 2019-09-09 01:58:07

FIREBASE WARNING: Exception was thrown by user callback in react native + FIREBASE, what causes it?

I'm trying to create a user and write data to the database

let _login = this.state.login.trim();
    let _password = this.state.password.trim();
    let _chosenDate = this.state.chosenDate.toString().substr(4, 12);
    let _phone = this.state.phone;
    let _sex = this.state.sex.toString();

    console.log(_password);
    console.log(_chosenDate);
    console.log(_phone);
    console.log(_sex);
    console.log(_login);


    if (_login == '') this.setState({ loginInputBorderColor: 'red' });
    if (_password == '') this.setState({ pwdInputBorderColor: 'red' });
    if (_phone == '') this.setState({ phoneInputBorderColor: 'red' });


    if (_login != '' && _password != '' && _phone != '' && _sex != '') {

      // Проверяем занят ли логин
      firebase.database().ref('users/' + _login).once('value', (snapshot) => {
        this.setState({ loginFromDb: snapshot.val().login })
      });

      
      if (this.state.loginFromDb == '') {

        //--
        firebase.auth().createUserWithEmailAndPassword(_login + "@" + _login + ".com", _password).then(function () {

          // Если пользователь создан, делаем запись его данных
          firebase.database().ref('users/' + _login).set({
            //password: _password,
            date: _chosenDate,
            phone: _phone,
            sex: _sex
          });

          // Если создать пользователя не удалось
        }, function (error) {
          // Handle Errors here.
          //var errorCode = error.code;
          //var errorMessage = error.message;
        });
        //--

      }



    } else {
      alert("Заполните все поля");
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question