Created
November 29, 2017 09:28
-
-
Save mauriciosoares/05a73e8ec15bc1c9000071f1ea94a67b to your computer and use it in GitHub Desktop.
This file contains 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 loadNumber() { | |
return fetch(API_URL); | |
} | |
const number = await loadNumber(); | |
// essa linha nao executa enquanto `loadNumber` nao tiver acabado | |
const multiplyRequest = fetch(API_URL, {data: number}); | |
const sumRequest = fetch(API_URL, {data: number}); | |
const promise = Promise.all(multiplyRequest, sumRequest).then((multiply, sum) => { | |
// esse callback só executa qnd as 2 requests acabarem | |
console.log(multiply); | |
console.log(sum); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment