1 | import fetch from "isomorphic-unfetch";
|
2 | import { hnApiBaseUrl } from "./hn-api-base-url";
|
3 |
|
4 | /**
|
5 | * `getBestStoriesIds` returns the list of up to 500 IDs of the best HN stories.
|
6 | *
|
7 | * @see {@link https://github.com/HackerNews/API#new-top-and-best-stories}
|
8 | */
|
9 | export async function getBestStoriesIds(): Promise<number[]> {
|
10 | const endpoint = `${hnApiBaseUrl}/beststories.json`;
|
11 | const res = await fetch(endpoint);
|
12 | const ids = await res.json();
|
13 | return ids;
|
14 | }
|