const post = useLoaderData('post')
const comments = useLoaderData('comments')
export async function postInfoLoader({ params }) {
const { id } = params
const [postResponse, commentsResponse] = await Promise.all([
fetch(ALL_POSTS_URL + id),
fetch(ALL_COMMENTS_URL + '?postId=' + id),
])
return {
post: await postResponse.json(),
comments: await commentsResponse.json(),
}
}
const {post, comments} = useLoaderData()
export async function postInfoLoader({ params }) {
const { id } = params;
const [postResponse, commentsResponse] = await Promise.all([
fetch(ALL_POSTS_URL + id),
fetch(ALL_COMMENTS_URL + '?postId=' + id),
]);
const post = await postResponse.json();
const comments = await commentsResponse.json();
return { post, comments };
}