DEV Community

Discussion on: How I've been misusing Async Await

Collapse
 
avalander profile image
Avalander

I mean, your function could be shortened to get rid of async/await altogether in this case.

const getItems = () => Promise.all([
  fetch('http://url.com/itemA'),
  fetch('http://url.com/itemB'),
])

In most cases you don't really need to declare an intermediate variable to hold a promise when you want to run stuff in parallel, you can just create the promise within a Promise.all.

Collapse
 
nipeshkc7 profile image
Arpan Kc

Thanks for the feedback, Avalander ! I will definitely incorporate these changes into the post.