Skip to content

Commit

Permalink
fix: disable throws if not found on server related posts
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasio committed Aug 22, 2024
1 parent 9ea83c3 commit aaf7b8f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions projects/wp-nextjs-app/src/components/ServerRelatedPosts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ export const ServerRelatedPosts: FC<{ post_id: number; category: string }> = asy
}) => {
const { data } = await queryPosts({
params: { postType: 'post', per_page: 3, category, exclude: [post_id] },
options: {
throwIfNotFound: false,
},
});

if (data.posts.length === 0) {
return null;
}

return (
<div>
<h2>Related Posts (Streamed from Server)</h2>
Expand Down

0 comments on commit aaf7b8f

Please sign in to comment.