Skip to content

Instantly share code, notes, and snippets.

@samuelastech
Created December 28, 2022 23:21
Show Gist options
  • Save samuelastech/fbf5d41613e4a1255c773dee5ab3aa9b to your computer and use it in GitHub Desktop.
Save samuelastech/fbf5d41613e4a1255c773dee5ab3aa9b to your computer and use it in GitHub Desktop.
Concurrence instead of synchronously
// 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