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

242
Views
¿Cuál es la razón por la que la función Async que tengo a continuación devuelve Promise { <pending> } en lugar de devolver el valor adecuado?

Cuando console.log() pagosResultados y resultadospendientes del código a continuación, puedo ver que los datos se registran correctamente. Sin embargo, justo en el último momento cuando intento devolver los pagos y estoy pendiente, veo los resultados como Promise { <pending> } en mi backend. ¿Cuál es el motivo y cómo puedo solucionar el problema aquí?

 const query = await pool.query(q); const payments = query.rows.filter(o => getCategory(o) === "payment"); const pending = query.rows.filter(o => getCategory(o) === "pending"); const inactive = query.rows.filter(o => getCategory(o) === "inactive"); const paymentsResults = payments.map(async order => { const A = ({ date: getDate(order), item: await getItem(order), total: getTotal(order), purchaser: getPurchaser(order), email: getEmail(order), paymentMethod: getPaidUsing(order), status: getStatus(order) }); return A; }); const pendingResults = pending.map(async order => { const B = { date: getDate(order), item: await getItem(order), total: getTotal(order), purchaser: getPurchaser(order), email: getEmail(order), status: getStatus(order) }; return B; }); return { payments: paymentsResults, pending: pendingResults, inactive: inactive }; };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

const paymentsResults = await Promise.all(payments.map(async order => { const A = { date: getDate(order), item: await getItem(order), total: getTotal(order), purchaser: getPurchaser(order), email: getEmail(order), paymentMethod: getPaidUsing(order), status: getStatus(order) }; return A; })); const pendingResults = await Promise.all(pending.map(async order => { const B = { date: getDate(order), item: await getItem(order), total: getTotal(order), purchaser: getPurchaser(order), email: getEmail(order), status: getStatus(order) }; return B; }));
  • La matriz de Promise debe ser resuelta por Promise.all antes de usar.
  • la función asíncrona siempre devuelve promesa.
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!