[Vuejs]-The email address is badly formatted firebase vue.js

1👍

Thank God I solved it.

The problem is solved by adding

 firebase.initializeApp(config);

right after

import firebase from 'firebase'

since I have already initialize Firebase in other files

the problem might be caused by javascript loading asynchronously .

👤dark.o

1👍

This works well. I tired to solve your ones. I have brought official firebase auth sample. Your user was not defined and while importing you must have use {} to prevent .auth() error.

       <template>
        <div class = "sign-up">
            <p> Let's create a new account</p>
            <input type="email" v-model="email" placeholder="Email"> 
            <input type="password" v-model="password" placeholder="Password">
            <button v-on:click="signUp">Sign Up</button>
    
        </div>
    </template>
    
    
    <script> 
    
    import {fb} from '../firebase';
    
          export default {
        name:'Signup',
        data() {
          return {
            email: "",
            password: "",
          }
        },
        methods: {
            signUp: function() {
                fb.auth().createUserWithEmailAndPassword(this.email, this.password)
                        .catch(function(error) {
                    // Handle Errors here.
                    var errorCode = error.code;
                    var errorMessage = error.message;
                    if (errorCode == 'auth/weak-password') {
                        alert('The password is too weak.');
                    } else {
                        alert(errorMessage);
                    }
                    console.log(error);
                    });    
            }
    
        }
    
      }
    
    
    
    </script>

Leave a comment