Skip to content

Instantly share code, notes, and snippets.

@nsulistiyawan
Created February 19, 2023 08:49
Show Gist options
  • Save nsulistiyawan/adb1d451770633fda7f540faabbcd165 to your computer and use it in GitHub Desktop.
Save nsulistiyawan/adb1d451770633fda7f540faabbcd165 to your computer and use it in GitHub Desktop.
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