See my comment, it's a little unclear what asyncResult and asyncResult2 are, because your first code block uses them as though they were variables containing promises (presumably for things already in progress), but your second code block calls them as functions and uses the result (presumably a promise).
If they're variables containing promises
...for processes already underway, then there's no problem with awaiting them individually, since they're already underway:
const result = {
result1: await asyncResult1, // Note these aren't function calls
result2: await asyncResult2,
};
That won't make the second wait on the first, because they're both presumably already underway before this part of the code is reached.
If they're functions
...that you need to call, then yes, to call them both and use the results Promise.all is a good choice. Here's a tweak:
const result = await Promise.all([asyncResult1(), asyncResult2()])
.then(([result1, result2]) => ({result1, result2}));
One of the rare places where using then syntax in an async function isn't necessarily the wrong choice. :-) Alternately, just save the promises to variables and then use the first option above:
const ar1 = asyncResult1();
const ar2 = asyncResult2();
const result = {
result1: await ar1,
result2: await ar2,
};
asyncResult1andasyncResult2appear to be variables that contain promises (presumably for things that have already started). But in your second code block, you're calling them and using the result of calling them as promises. Which is it in your real code? (Also note that you're missing[]around what you're passingPromise.all.)[]missing, the examples above are more meant to explain my question.