Created
February 19, 2023 08:49
-
-
Save nsulistiyawan/adb1d451770633fda7f540faabbcd165 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function loadInitialData(){ | |
//let's assume that each request will take 600ms | |
try { | |
const user = await fetchUser(); // run 1st | |
const product = await fetchProduct(); // wait 600ms for user req to run | |
const other = await fetchOther(); // wait 600ms for product req to run | |
} catch(error) { | |
console.log(error); | |
} | |
} | |
// fetch user + fetch product + fetch other: total 1800ms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment