Created
December 28, 2022 23:21
-
-
Save samuelastech/fbf5d41613e4a1255c773dee5ab3aa9b to your computer and use it in GitHub Desktop.
Concurrence instead of synchronously
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
// Wrong away | |
const poolCountResponse = await api.get('http://localhost:3333/pools/count') | |
const guessCountResponse = await api.get('http://localhost:3333/guesses/count') | |
// Correct way | |
const [poolCountResponse, guessCountResponse] = await Promise.all([ | |
api.get('http://localhost:3333/pools/count'), | |
api.get('http://localhost:3333/guesses/count') | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment