DEV Community

[Comment from a deleted post]
Collapse
 
djheru profile image
Philip Damra • Edited

It's not a stupid idiom, it's just passing an array to an async function and receiving an array as a return value. If it's easier for you, you can type

const getAllStatesPromise = GetAllStates();
const fetchAddressTypesPromise = FetchAddressTypes();
const findPhoneTypesPromise = FetchPhoneTypes();

const promisesToAwait = [
  getAllStatesPromise, 
  fetchAddressTypesPromise, 
  findPhoneTypesPromise 
];

const resolvedPromises = await Promise.all(promisesToAwait);

const states = resolvedPromises[0];
const addressTypes = resolvedPromises[1];
const phoneTypes = resolvedPromises[2];

but why would you want to do that???