Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

76
Visualizações
Accessing JSON file with index.html

I have my index.html & data.json file both in the same directory
so how do I access the json file from index.html?

maybe something like this in the index.html :

<script>
  const data= require('./data.json') //obviously this won't work
</script>

according to all the answers for this question, you have to first send the index.html file then make a fetch request back to the server to send you the json file

but is there no way to send both of them together to avoid delay?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can embed the JSON in the HTML document, either by hard-coding it or using server-side programming to generate the HTML.

about 4 years ago · Juan Pablo Isaza Relatório

0

You can fetch the file for where it's being server.

<script>
  (async () => {
    raw = await fetch('/data.json')
    data = await raw.json()
  })().catch(console.warn)
</script>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda