Skip to content

Commit

Permalink
Add handling of non-post post item responses
Browse files Browse the repository at this point in the history
  • Loading branch information
jonamil committed Jun 29, 2024
1 parent 3e48fec commit 0925134
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/stores/ContentStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,14 @@ export const useContentStore = defineStore('content', () => {
response.json()
);

if (fetchedItem === null) return null;
// if request returns null or fetched item is not a post, return null
if (
fetchedItem === null ||
!fetchedItem.type ||
!['story', 'poll', 'job'].includes(fetchedItem.type)
) {
return null;
}

// parse URL string of fetched item to separate hostname and pathname
const postItem: HackerNewsItem = Object.assign({}, fetchedItem, {
Expand Down

1 comment on commit 0925134

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for hackernews-dot-cool ready!

✅ Preview
https://hackernews-dot-cool-co9c465gw-jonamil-56ba8df7.vercel.app

Built with commit 0925134.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.