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

275
Views
Promises.all () - cómo verificar si todos devuelven indefinidos

En el siguiente código, quiero verificar si promisesArray devuelve algún dato.

 const promisesArray = [this.loadData1(),this.loadData2()] Promise.all(promisesArray).then(() => { console.log('promises.all callback -> ', promisesArray[0]) }

El console.log anterior puede producir lo siguiente:

 Promise {<fulfilled>: undefined} [[Prototype]]: Promise [[PromiseState]]: "fulfilled" [[PromiseResult]]: undefined

Si no especifico el índice 0, repite el mismo resultado para ambas llamadas de función pasadas a Promises.all .

Estoy tratando de acceder al valor undefined en ambas respuestas, pero no estoy seguro de cómo hacerlo si cada tecla es una matriz multidimensional.

Si alguien tiene alguna idea sobre cómo verificar fácilmente si ambas funciones resultan undefined , estaría muy agradecido.

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

0

Promise.all(promisesArray) .then((res) => res.every((r) => r === undefined)) .then((isUndefined) => { // if isUndefined is true then all promises returned undefined });
about 4 years ago · Juan Pablo Isaza Report

0

Usando la sintaxis async / await:

 const results = await Promise.all([this.loadData1(),this.loadData2()]); if (results.every(r => r === undefined)) { console.log('No 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!