javascript - HTML, CSS, JS Script error. Error Interpretting Stack -
i working on to-do list application using firebase, error script error. error interpreting stack
. has no obvious meaning, don't know think.
i tried commenting out of js still got same result. heard external link, adding crossorigin=anonymous
didn't help.
all code worked me before, error new me.
var config = { apikey: "aizasybiv0dppiwuzadvgfmkipf7gsykivt8n4m", authdomain: "to-do-332c9.firebaseapp.com", databaseurl: "https://to-do-332c9.firebaseio.com", projectid: "to-do-332c9", storagebucket: "to-do-332c9.appspot.com", messagingsenderid: "281739919235" }; firebase.initializeapp(config); const txtemail = document.getelementbyid('txtemail'); const txtpassword = document.getelementbyid('txtpassword'); const btnlogin = document.getelementbyid('btnlogin'); const btnsignup = document.getelementbyid('btnsignup'); const btnlogout = document.getelementbyid('btnlogout'); var ref = firebase.database().ref(''); btnlogin.addeventlistener('click', e => { document.getelementbyid('form').classlist.add('hide'); const email = txtemail.value; const pass = txtpassword.value; const auth = firebase.auth(); const promise = auth.signinwithemailandpassword(email, pass); promise.catch(e => console.log(e.message)); ref = firebase.database().ref(''); }); btnsignup.addeventlistener('click', e => { const email = txtemail.value; const pass = txtpassword.value; const auth = firebase.auth(); const promise = auth.createuserwithemailandpassword(email, pass); promise.catch(e => console.log(e.message)); }); firebase.auth().onauthstatechanged(firebaseuser => { if (firebaseuser) { btnlogout.classlist.remove('hide'); document.getelementbyid('form').classlist.add('hide'); } else { btnlogout.classlist.add('hide'); document.getelementbyid('messagestitle').classlist.add('hide'); } });
.container { width: 70%; height: 100%; background: #87b5ff; margin: 10% auto; color: #fff; padding: 20px; border-radius: 10px; max-width: 400px; } #signin { margin: auto; padding-top: 10px; } .hide { display:none; }
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>to-do</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoiresju2yc3z8gv/npezwav56rsmlldc3r/azzgrngxqqknkkofvhfqhnuweyj" crossorigin="anonymous"> <link rel="stylesheet" href="style.css"> </head> <body> <div id="form" class="container"> <h3>login</h3> <form id="signin"> <input type="email" class="form-control" id="txtemail" placeholder="email"> <input type="password" class="form-control mb-3" id="txtpassword" placeholder="password"> </form> <button id="btnlogin" class="btn btn-primary">login</button> <button id="btnsignup" class="btn btn-success">sign up</button> <button id="btnlogout" class="btn btn-info hide">logout</button> </div> <script src="https://www.gstatic.com/firebasejs/4.3.1/firebase.js"></script> <script src="main.js"></script> </body> </html>
Comments
Post a Comment