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

107
Views
Cómo obtener varios archivos sincrónicamente y cargarlos en una sola variable

¿Cómo recomendaría que busque varios archivos (en particular, archivos CSV) y los fusione en una sola variable? Intenté usar lo siguiente y estoy bastante seguro de que entendí algo sobre la sintaxis/lógica de la promesa incorrecta, ya que es un área en la que soy bastante nuevo, pero puede ser otro problema. Aquí está mi intento actual:

 fetcher(specURL).then(async (spec) => { let rawData; if (typeof spec.dataURL === "string") { rawData = await fetcher(spec.dataURL); } else if (typeof spec.dataURL === "array") { rawData = {}; await spec.dataURL.forEach(async (url, i) => { rawData[i] = await fetcher(url); }); } console.log(rawData); }

Como puede ver, uso un json de especificación (especificación) que articula qué URL buscar. Si es una matriz, me gustaría obtener varios archivos en una matriz.

Estoy usando mi función de búsqueda, que es la siguiente (¡también se agradece cualquier recomendación para mejorarla!

 async function fetcher(url, type) { let fetched = await fetch(url); fetched = await fetched.text(); if (type == undefined) { type = url.split(".").pop(); } if (type == "json") { fetched = JSON.parse(fetched); } else if (type == "csv") { fetched = Papa.parse(fetched, { header: true }).data; } return fetched;

}

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!