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

193
Vistas
How to get the promise state when creating a new Auth user in firebase using javascript

I am able to create a new user in firebase Authentication like this:

const status = firebase.auth().createUserWithEmailAndPassword(email, password);   
console.log(status);

The console shows the output as this:

Promise {<pending>}
[[Prototype]]: Promise
[[PromiseState]]: "rejected"
[[PromiseResult]]: FirebaseError: Firebase: The email address is badly formatted.

How would I get the PromiseState from my status variable?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The promise state is whether the promise resolves or rejects. If you're using the .then approach to working with promises, you can supply a second callback function to handle the error case:

firebase.auth().createUserWithEmailAndPassword(email, password)
  .then(status => {
    // If it gets to here, the promise resolved
    console.log(status);
  }, error => {
    // If it gets to here, the promise rejected
    console.log(error);
  });

// Or, equivalently:
firebase.auth().createUserWithEmailAndPassword(email, password)
  .then(status => {
    console.log(status);
  })
  .catch(error => {
    console.log(error);
  });

If you're using async/await, then you handle the error case with a try/catch

async someFunction() {
  try {
    const status = await firebase.auth().createUserWithEmailAndPassword(email, password);
    // If it gets to here, the promise resolved
    console.log(status);
  } catch (error) {
    // If it gets to here, the promise rejected
    console.log(error);
  }
}
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