Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

211
Vistas
how to solve const auth not defined?

i want to use firebase authentication, so i declared a constant named auth in my html body script and i wanted to use it in my auth.js file but it say it's not defined and i want to know how to solve the probleme. this is the code i wrote: this is the code in my html file:

<!-- Firebase -->
<script type="module">
    // Import the functions you need from the SDKs you need
    import { initializeApp } from "https://www.gstatic.com/firebasejs/9.0.2/firebase-app.js";
    import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.0.2/firebase-analytics.js";
    import { getAuth, createUserWithEmailAndPassword } from "https://www.gstatic.com/firebasejs/9.0.2/firebase-auth.js";
    import { getFirestore } from "https://www.gstatic.com/firebasejs/9.0.2/firebase-firestore.js";
    // TODO: Add SDKs for Firebase products that you want to use

    // Your web app's Firebase configuration
    // For Firebase JS SDK v7.20.0 and later, measurementId is optional
    const firebaseConfig = {
        apiKey: "AIzaSyC3GLIN5TBmCDoTfy0dEOgOdvVvqNw-ric",
        authDomain: "auth-project-38aaa.firebaseapp.com",
        projectId: "auth-project-38aaa",
        storageBucket: "auth-project-38aaa.appspot.com",
        messagingSenderId: "431888894254",
        appId: "1:431888894254:web:71bb9b250fbb8a21edd2bf",
        measurementId: "G-6BBPCJ3814"
    };
    // Initialize Firebase
    const app = initializeApp(firebaseConfig);
    const analytics = getAnalytics(app);
    const auth = getAuth(app);
    const db = getFirestore(app);
                
</script>
<!-- JS -->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="js/auth.js"></script>

and this is the code in my auth.js:

const signUpForm = document.querySelector('#register-form');

signUpForm.addEventListener('submit', (e) => {
    e.preventDefault();
    // get user info
    const name = signUpForm['name'].value;
    const email = signUpForm['email'].value;
    const pass = signUpForm['pass'].value;
    const rePass = signUpForm['re_pass'].value;
    const agreeTerm = signUpForm['agree-term'].value;

    console.log(name, email, pass, rePass, agreeTerm);
    // sign up the user
    auth.createUserWithEmailAndPassword(email, pass).then(cred => {
        console.log(cred); 
    });
});  
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The auth.createUserWithEmailAndPassword is for the Firebase SDK v8 and earlier, or for compat mode in v9.

The new syntax is according to the documentation on creating a user:

createUserWithEmailAndPassword(auth, email, pass).then(cred => {
    ...
});
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda