Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
El método asíncrono siempre devuelve verdadero

Estoy implementando una funcionalidad de inicio de sesión con firebase y React Native. El método handleLogin siempre devuelve exit succeed() . Si elimino el success() , obtengo:

[Rechazo de promesa no manejado: TypeError: undefined no es un objeto (evaluando 'result2.failed')]

 export default async function login(credentials) { let result2= succeed(); result2 = await handleLogin(credentials.email, credentials.password); if(result2.failed()){ return fail({password: "Login failed"}); } else{ return succeed(); } } const handleLogin = async(email,password) => { auth.signInWithEmailAndPassword(email, password) .catch(function(error) { console.log(error); return fail("failed"); }) return succeed(); // or fail() in which case method always returns fail()

También intenté usar .then() pero sigo obteniendo un error de objeto indefinido si no devuelvo succeed() o fail() al final de handleLogin() :

 auth.signInWithEmailAndPassword(email, password) .then(function(){return succeed();}) .catch(function(error) { console.log("we fail"+error); return fail("failed"); })
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Resolví el problema agregando una declaración de devolución:

 return auth.signInWithEmailAndPassword(email, password).then(function(){return succeed();}).catch(function(error) { return fail("Login Attempt Failed\n"+error);})
about 4 years ago · Juan Pablo Isaza Report

0

Es un problema conocido de Firebase. Me pasó algo similar en el código angular.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!