import { fetch } from "https://esm.town/v/std/fetch";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
export async function hnTopTenStories() {
const topStories: Number[] = await fetch(
"https://hacker-news.firebaseio.com/v0/beststories.json?print=pretty",
).then((res) => res.json());
const top10Stories = await Promise.all(
topStories.slice(0, 10).map(async (id) => {
return await fetchJSON(
`https://hacker-news.firebaseio.com/v0/item/${id}.json`,
);
}),
);
return top10Stories;
}