Closed Luukth closed 3 years ago
I implemented the suggestion from Viraj Singh:
I would fix your problem at 8:20 by doing something like: Promise.all( ['0-10', '10-20', '30-40' ].map(fetchAndUpdateGrades)) async function fetchAndUpdateGrades( grade ) { // fetching data for a given grade const result = await fetch('localhost:8000/'+grade); // updating UI as soon as I get data back from server for this grade document.getElementById(grade).innerText = result.data; } https://www.youtube.com/watch?v=eI_EQNTxF6U
I would fix your problem at 8:20 by doing something like:
Promise.all( ['0-10', '10-20', '30-40' ].map(fetchAndUpdateGrades))
async function fetchAndUpdateGrades( grade ) {
// fetching data for a given grade const result = await fetch('localhost:8000/'+grade);
// updating UI as soon as I get data back from server for this grade document.getElementById(grade).innerText = result.data;
} https://www.youtube.com/watch?v=eI_EQNTxF6U
The results will now display as soon as they come in. When all the results are in the duration will be displayed/calculated.
Good fix! Thanks Luukth and Viraj Singh for the fix!
I implemented the suggestion from Viraj Singh:
The results will now display as soon as they come in. When all the results are in the duration will be displayed/calculated.