Created
January 21, 2023 09:46
-
-
Save Rahmanism/ecadc966ecaef019db6ab39e5504fbe5 to your computer and use it in GitHub Desktop.
Using Promise.allSettled instead of Promise.all for concurrency in JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function getData() { | |
const results = await Promise.allSettled({ | |
fetchUser(), | |
fetchProduct() | |
}) | |
const [user, product] = handle(results) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment