Created
July 27, 2023 13:06
-
-
Save coproduto/840606d3286a7b3fdb7b8ec738957ab7 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
Promise.all([ | |
fetch('firstUrl'), | |
fetch('secondUrl'), | |
fetch('thirdUrl') | |
]).then(([firstResponse, secondResponse, thirdResponse] => { | |
// faz o que quiser aqui | |
}).catch((error) => { /* trata erro aqui */ }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Esse código não utiliza a resposta da primeira requisição na segunda, e assim por diante.
As 3 requisições acontecerão "ao mesmo tempo".
Esse cenário não serve para descrever o callbackHell.
O callbackHell se dá quando você precisa executar Promises dependentes em sequência, com uma dependendo do resultado da outra.