import { fetchShelf } from '../../src/shelves'; import { fetchPost } from '../../src/posts'; import { fetchPostComments } from '../../src/comments'; async function getPageData(pageContext) { const [shelf, post, comments] = await Promise.all([ fetchShelf(pageContext.routeParams.shelfId), fetchPost(pageContext.routeParams.postId, pageContext.session.user), fetchPostComments(pageContext.routeParams.postId), ]); if (!shelf) { throw new Error('This shelf does not exist'); } if (!post) { throw new Error('This post does not exist'); } return { shelf, post, comments, }; } export { getPageData };