ES6 allows the reverse as well which means the method above can be even neater, Also since the entire method is marked async there is no need for the try/catch if your not interested in the error (as in the example above).
async
try/catch
async function getAllUserData() { let [ userInfo, userFriends, userSkills ] = await Promise.all([ getUserInfo(), countUserFriends(), getUserSkills() ]; return {userInfo, userFriends, userSkills}; }
Some Promise libraries offer a hash function for this purpose:
hash
async function getAllUserData() { return RSVP.hash({ userInfo: getUserInfo(), userFriends: countUserFriends(), userSkills: getUserSkills() }); }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
ES6 allows the reverse as well which means the method above can be even neater, Also since the entire method is marked
async
there is no need for thetry/catch
if your not interested in the error (as in the example above).Some Promise libraries offer a
hash
function for this purpose: