Skip to content

Instantly share code, notes, and snippets.

@SZharkov
Created December 23, 2022 21:50
Show Gist options
  • Save SZharkov/d2337ed0540d8e779f2ab3bc9c60b7a9 to your computer and use it in GitHub Desktop.
Save SZharkov/d2337ed0540d8e779f2ab3bc9c60b7a9 to your computer and use it in GitHub Desktop.
async function fetchUserResources() {
const [posts, photos, todos] = await Promise.allSettled([
fetch('https://jsonplaceholder.typicode.com/posts/1'),
fetch('https://jsonplaceholder.typicode.com/photos/1'),
fetch('https://jsonplaceholder.typicode.com/todos/1')
]);
console.log(posts);
// {status: "fulfilled", value: {"holds_the_posts_object"}}
console.log(photos);
// {status: "fulfilled", value: {"holds_the_photos_object"}}
console.log(todos);
// {status: "rejected", reason: The error}
return {posts, photos, todos};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment