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

114
Views
"asyncing" nueva promesa (resolver, rechazar)

Básicamente, lo que me ves haciendo aquí es "sincronizar" una promesa que solo estoy creando.

¿Es esa una forma desaconsejable, anti-patrón, fatal o tonta de escribir una promesa? Si es así, ¿por qué?

 function returnSomething(name) { return new Promise(async (resolve, reject) => { try { //some dealings.... const somethingElse = await returnSomethingElse(); //do some stuff with 'somethingElse' resolve(somethingElse); } catch(error) { //some dealings.... reject(error); return; } }); }

La tentación de hacer esto es básicamente muy fácil de explicar. Quiero evitar el infierno .then().then().then() si devuelvo una promesa como resultado de una promesa.

También quería evitar trabajar con algo como esto:

 function returnSomething(name) { return new Promise((resolve, reject) => { //some dealings.... returnSomethingElse().then((somethingElse) => { //do some stuff with 'somethingElse' resolve(somethingElse); }).error((error) => { //some dealings.... reject(error); return; }); } }); }

Gracias por adelantado.

about 4 years ago · Juan Pablo Isaza
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!