Skip to content

Instantly share code, notes, and snippets.

@dumboluzz
Last active October 9, 2022 15:51
Show Gist options
  • Save dumboluzz/cc678c453549b010a6b7b57bbb9c56dc to your computer and use it in GitHub Desktop.
Save dumboluzz/cc678c453549b010a6b7b57bbb9c56dc to your computer and use it in GitHub Desktop.
await (async () => {
try {
const userRes = await fetch(`/api/loggedInUser`);
const user = await userRes.json();
if (!user?.id) {
throw new Error(`No user id found`);
}
const responses = await Promise.all([
fetch(`/api/user/${user.id}/comments`),
fetch(`/api/user/${user.id}/books`),
]);
const [comments, books] = await Promise.all(
responses.map((res) => res.json())
);
console.log(books, comments);
} catch (error) {
console.error(error);
}
})();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment