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

240
Visualizações
Can you use 2 async functions at the same time when working with 2 .json files? (Two different .json text files)

If not then how can you work with 2 .json files at the same time? It does't seem to work so if there exists another method I should try and use that. If you could provide the correct syntax to achieve the goal it would be appreciated. Does the second .json file ever get processed?

sync function populate() {

    const requestURL = 'nascar.json';
    const request = new Request(requestURL);
    
    const response = await fetch(request);
    const nascarDrivers = await response.json();
    
    findDriver(nascarDrivers);
}

async function texas() {

    const requestURL = 'texasMS.json';
    const request = new Request(requestURL);
    
    const response = await fetch(request);
    const texasLaps = await response.json();
    
    findLaps(texasLaps);
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If you run them one by one, without awaiting them, they will run in parallel (sort-of).

populate()
texas()

If you want to wait for the results as they come back, you can use Promise.all:

const promises = [
  populate(),
  texas(),
]
Promise.all(promises).then((results) => {
  const [populateRes, texasRes] = results
  // ...
})
// or
const results = await Promise.all(promises)
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