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

204
Views
¿Cómo usar async.eachSeries en nodeJS?

Quiero iterar a través de una lista de elementos de manera sincrónica y usar el resultado de cada paso en el siguiente paso. ¿Alguien puede corregir/sugerir la lógica del código que estoy usando?

 const async = require('async') async.eachSeries([1, 2, 3, 4, 5], function downloadChunk (chunkID, asyncCallback) { console.log(chunkID) const result = `This is a result from ${chunkID} call and should be used somewhere in ${chunkID + 1}` // How should I pass this result to next step asyncCallback() }, function complete (err) { if (err) console.log('Error: ' + err) console.log('this is the end. All the variables have been used') } )
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Simplemente puede crear una variable fuera de async.eachSeries así:

 const async = require('async') var result = null; async.eachSeries([1, 2, 3, 4, 5], function downloadChunk (chunkID, asyncCallback) { console.log(chunkID) console.log('Result from previous call', result); // reassign new value to the result result = `This is a result from ${chunkID} call and should be used somewhere in ${chunkID + 1}` asyncCallback() }, function complete (err) { if (err) console.log('Error: ' + err) console.log('this is the end. All the variables have been used') } )
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!