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

81
Views
Valor de retorno en lugar de promesa sin esperar

Como la función principal no es compatible con async. Necesito hacer una llamada sin esperar y obtener el return value . Como se sugiere en la mayoría de las publicaciones, se aplicó la promesa con then valor de retorno. Pero se imprime como "promesa" en lugar de devolver "valor".

¿Puede compartir cómo lograr un valor de retorno en lugar de una promesa?

sandbox de código: https://codesandbox.io/s/await-without-async-and-return-value-qbs7t?file=/src/index.js


 await isEnable(data) { try { ... return true; } catch (e) { console.error(e); } } } const getEnableStatus=(data) =>{ return isEnable(data).then((result) => {console.log(result); return result;}); //this prints correctly but, need this in return result. } console.log(getEnableStatus(data)); //it always print 'promise'. how to get value here instead of promise.
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Pase una devolución de llamada a la función getEnableStatus y luego llámela con los datos devueltos.

 // Mock function that resolves after // two seconds function isEnable() { return new Promise((res, rej) => { setTimeout(() => res('Hallo!'), 2000); }); } // Accept a callback, and call it with the data function getEnableStatus(data, callback) { isEnable(data).then(callback); } // The callback logs the data getEnableStatus('data', function (data) { console.log(data); });

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!