Skip to content

Instantly share code, notes, and snippets.

@itaditya
Created March 31, 2018 21:22
Show Gist options
  • Save itaditya/5a402e5c4754ca70a86bc9a5d3356f4a to your computer and use it in GitHub Desktop.
Save itaditya/5a402e5c4754ca70a86bc9a5d3356f4a to your computer and use it in GitHub Desktop.
Snippet for Avoiding the async/await hell medium article
async function orderItems() {
const items = await getCartItems() // async call
const noOfItems = items.length
for(var i = 0; i < noOfItems; i++) {
await sendRequest(items[i]) // async call
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment