Skip to content

Commit

Permalink
filter out ask_hn posts
Browse files Browse the repository at this point in the history
  • Loading branch information
jcosentino11 committed Sep 3, 2024
1 parent 19ca2c1 commit 63badf3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions clients/HNClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export class DefaultHNClient {
try {
// TODO filter out Ask HN, etc
const response = await fetch(
`https://hn.algolia.com/api/v1/search?tags=front_page&hitsPerPage=${numberOfStories}`,
`https://hn.algolia.com/api/v1/search?tags=front_page&hitsPerPage=${numberOfStories * 2}`,
{timeout: this.responseTimeout}
);
const data = await response.json();
return data.hits;
return data.hits.filter((hit: any) => !hit._tags.includes('ask_hn')).slice(0, numberOfStories);
} catch (error) {
console.error(error);
return [];
Expand Down

0 comments on commit 63badf3

Please sign in to comment.