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

199
Visualizações
Get Multiple instances of dataset in document.currentScript, But returning null

I am storing my json files in script tag. All the data are included in mutiple json files. I am getting the data with the help of fetch Api and then converting the response into JSON format. But when i try to access the dataset used in the currentScript, the second instance returns null and throws an error in the browser console as 'cannot read properties of undefined'

Here is the code that i am using

async function getDataset() {
const widgetID = document.currentScript.id;
 const wc = "."+widgetID;
const fetchConfig = await fetch(document.currentScript.dataset.config);
const config = await fetchConfig.json();
const fetchCurrency = await fetch(document.currentScript.dataset.currency);
const curreny = await fetchCurrency.json();
}

HTML:

<script async src="js/widget.js" data-config="js/config.json" data-currency="js/currency.json"></script>
about 4 years ago · Juan Pablo Isaza
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