1

I am trying to make a simple web auth page using firebase auth but getting this error everytime

//HTML: 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="https://www.gstatic.com/firebasejs/5.2.0/firebase.js"></script>
</head>
<body>
    <label>Email</label>
    <input type="email" id="txtEmail"><br/>
    <br/>
    <label>Password</label>
    <input type="password" id="txtPass"><br/><br/>
    <button id="loginButton" onclick="validate();">Login</button>
    <script src="auth2.js"></script>
</body>
</html>

//JS File

// Initialize Firebase
  var config = {
    apiKey: "YOUR_API_KEY",
    authDomain: "YOUR_DOMAIN",
    databaseURL: "YOUR_DB_URL",
    projectId: "PROJECT_ID",
    storageBucket: "STORAGE",
    messagingSenderId: "SENDER_ID"
  };
  firebase.initializeApp(config);

    var email = document.getElementById("txtEmail").value;
    var pass = document.getElementById("txtPass").value;


    function validate(){
        const auth = firebase.auth();
        const promise = auth.signInWithEmailAndPassword(email, pass);
        promise.catch(function(error){
            console.log("Got a error", error);
        })
    }

I get this error in console:

Fr {code: "auth/invalid-email", message: "The email address is badly formatted."}
kyun
  • 7,487
  • 4
  • 21
  • 44
Madara Uchiha
  • 39
  • 1
  • 8

0 Answers0