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

199
Vistas
What's the right way to load json files in browsers

I have built a node library loading json files like this

var FILE_PATH = path.join(
  __dirname,
  '../data/data.json'
);

function loadMyJsonFile() {
  return JSON.parse(
    fs.readFileSync(
      FILE_PATH,
      constants.DEFAULT_ENCODING
    )
  );
}

The code works fine on server side. I see this error in Chrome console when the function is executed in browser.

Uncaught TypeError: fs.readFileSync is not a function

I googled a bit and I don't think I can use fs in browser code. What's the right way of loading json files in browser?

over 4 years ago · Santiago Trujillo
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