'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);
}


Solution 1:[1]

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)

Solution 2:[2]

You might be missing:

import h11

https://h11.readthedocs.io/_/downloads/en/stable/pdf/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 casraf
Solution 2 nOs