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

194
Views
¿El valor de retorno es nulo cuando el valor de retorno se coloca dentro de la función .then?

He estado tratando de solucionar el siguiente problema durante los últimos dos días. Quiero crear un usuario y luego devolver una lista como se muestra a continuación:

 exports.createUser = functions.https.onCall((data,context) => { try { admin.auth().createUser({ email: "kevin3928@gmail.com" password: "a3tbmz" }).then((arg) => { // a) if I return a variable here it doesn't work }); // b) if I return a variable here it works } });

Devolver una variable usando el método b) funciona pero necesito devolver la variable usando el método a). No puedo usar async y await porque recibiré el siguiente error:

 error Parsing error: Unexpected token => ✖ 1 problem (1 error, 0 warnings)

Agradezco si alguien me puede ayudar con esto, pasé todo el fin de semana tratando de resolver esto...

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Debe devolver un valor del código de nivel superior de su función; de lo contrario, Cloud Functions puede/terminará su código antes de que se complete la operación asíncrona.

 exports.createUser = functions.https.onCall((data,context) => { try { return admin.auth().createUser({ email: "kevin3928@gmail.com" password: "a3tbmz" }).then((arg) => { return "result"; }).catch((err) => { return err; }); } });

Consulte también el segundo fragmento de código en la documentación sobre cómo devolver el resultado , que hace algo similar.

about 4 years ago · Juan Pablo Isaza Report

0

probar

 let userCreated = false exports.createUser = functions.https.onCall((data,context) => { try { admin.auth().createUser({ email: "kevin3928@gmail.com" password: "a3tbmz" }) userCreated = true if(userCreated){ return // the object you wanted to return } } catch(err){ throw new Error(err) } });
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!