say you have a function like

const doFetch = async (url, token) => fetch(url+token);

and an object like

const accounts = {'a': 'foo.com', 'b': 'bar.com'};

how would you call the doFetch function for each property of the accounts object in such a way that you end up with a result like

const results; // {'a', ['results', 'of', 'doFetch('foo.com', 'a')'], 'b': ['results', 'of', 'doFetch('bar.com', 'b')']}

here's chatGPT's suggestion

#javaScript

@schizanon you might want to use `Promise.allSettled` instead of `Promise.all` so that a single failed call doesn't abort all of them, but that aside, what about something like this if you don't like the direct indexing?

Object.fromEntries(await Promise.all(Object.entries(args).map(async ([key, arg]) => [key, await asyncFunction(arg)])))

of course could be simplified into smaller helper functions instead of a one liner though 😅

@schizanon oh i'm late to the party, essentially the same answer as here https://mastodon.social/@emilis@fosstodon.org/110751139741621242 😆