Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

383
Vistas
How can I fetch multiple JSON files from one directory in React?

This is a react project. I have a folder name data inside src where there are multiples JSON files. Now I need to fetch all the JSON files from data directory but the problem is I don't know the names of the JSON files so how can I fetch all of the JSON files from data folder in React?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can also use "Promise.all" in order to await every single file as shown below. Use the method suggested by the answer above, and implement the code below as well in order to get the best result!

Promise.all([promise1, promise2, promise3]).then((values) => {
  console.log(values);
});

about 4 years ago · Juan Pablo Isaza Denunciar

0

If you want to iterate through them you should create an index.ts file in your JSONs dir, and import all files in it, and export all of them as a single array that contains all the JSONs, and import it anywhere and do what you want.

index.js:

import file1 from './file1.json';
import file2 from './file2.json';

let items = [file1, file2];

export default items;

anywhere else in your app:

import items from 'URLS_DIR';
console.log(items, ` <--- items ----`); // iterate through them

Files Dir

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda