Sistem authentikasi firebase

video channel sekolahkoding seri firebase (error firebase.auth is not a function di function handlesigup()) <a href=' https://www.youtube.com/watch?v=UekFliePV1s&t=20s '> https://www.youtube.com/watch?v=UekFliePV1s&t=20s </a>

<script>
        // Your web app's Firebase configuration
        var firebaseConfig = {
            apiKey: "AIzaSyBYnKitDftzKXyNef5pwinS2_OJ2EppN5g",
            authDomain: "rugged-cooler-238404.firebaseapp.com",
            databaseURL: "https://rugged-cooler-238404.firebaseio.com",
            projectId: "rugged-cooler-238404",
            storageBucket: "rugged-cooler-238404.appspot.com",
            messagingSenderId: "473855077141",
            appId: "1:473855077141:web:85456a418fa69ed1"
        };
        // Initialize Firebase
        firebase.initializeApp(firebaseConfig);

        var auth = firebase.auth();


        // prepare elements
        var email_text = document.getElementById('email_text');
        var password_text = document.getElementById('password_text');
        var login_btn = document.getElementById('login');
        var signup_btn = document.getElementById('signup');
        var logout_btn = document.getElementById('logout');

        signup_btn.addEventListener('click', handleSigup);
        login_btn.addEventListener('click', handleLogin);

        logout_btn.addEventListener('click', handleLogout);

        function handleSigup() {
            auth.createUserWithEmailAndPassword(email_text.value, password_text.value)
            .then(function (data) {
                    console.log("## login ##")
                    console.log(data)
                })
                .catch(function (err) {
                    console.log(err)
                })
        }

        function handleLogin() {

        }

        function handleLogout() {

        }
    </script>

avatar Absor
@Absor

4 Kontribusi 0 Poin

Diperbarui 5 tahun yang lalu

1 Jawaban:

Di menit 2:56 video tersebut harus menambahkan Firebase SDK

<pre> // Baris 25 Index.HTML &lt;script src="https://www.gstatic.com/*****(sesuaikan dengan video) &gt;&lt;/script&gt; </pre>

avatar IfanZalukhu
@IfanZalukhu

217 Kontribusi 158 Poin

Dipost 5 tahun yang lalu

Tanggapan

makasih om sudah bisa tapi jadi error "Uncaught TypeError: Cannot read property 'addEventListener' of null" kenapa ya?

Itu bisa terjadi ID di html berbeda dengan ID yg kamu panggil di JS. coba pastikan dulu sama

Login untuk ikut Jawaban