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

206
Views
Falta de orden de ejecución en forEach (async y await) al nodo js

Tengo una función para cada espera y da una cadena y la agrega a una matriz, pero el registro que obtuve más tarde muestra que la matriz está vacía y se realiza antes de que finalice for each.

 const paths: Array<string> = []; await filterFiles.forEach((data, index) => { fileSave(data, `${name}@${index}`, National_Code, "medium", "image") .then((data: string) => { paths.push(data); console.log(paths); console.log("log 2"); }) .catch((err) => { res.status(500).json("There is a problem saving the files"); return err; }); }); console.log(paths); console.log("log 1");

Resultado :

 [] log 1 [ 'image/Czech@0_0927735016.jpeg' ] log 2 [ 'image/Czech@0_0927735016.jpeg', 'image/Czech@1_0927735016.jpeg' ] log 2

¿Qué hice mal?

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!