Paginated Hacker News job feed loading details 5 at a time
Build a feed of the newest job postings from the public Hacker News API. The API returns hundreds of job ids, but each posting’s details is a separate request, so load the details in pages of 5 and let the user ask for more.
The starter code declares API_BASE = 'https://hacker-news.firebaseio.com/v0' and PAGE_SIZE = 5.
GET {API_BASE}/jobstories.json returns an array of job ids, newest first.GET {API_BASE}/item/{id}.json returns one posting:// GET .../jobstories.json
[47001, 47002, 47003, ...]
// GET .../item/47001.json
{
"id": 47001,
"by": "lumenlabs",
"time": 1793188800, // Unix time in seconds
"title": "Lumen Labs is hiring a frontend engineer",
"url": "https://lumenlabs.example.com/careers", // may be missing
"type": "job"
}
PAGE_SIZE ids only, in parallel.Loading jobs….<a href>) to its url. If it has no url, link to https://news.ycombinator.com/item?id={id}.by {by} · {date}, where the date is time formatted as YYYY-MM-DD in UTC, for example by lumenlabs · 2026-10-28.Showing 5 of 12 jobs.PAGE_SIZE postings and appends them. The postings already shown stay visible.Loading…).Could not load jobs and a Try again button. Clicking it reloads the feed from the start.No jobs right now.The API has 12 job ids:
mount Loading jobs…
first page 5 postings (ids 1–5) Showing 5 of 12 jobs [Load more]
Load more 10 postings (ids 1–10) Showing 10 of 12 jobs [Load more]
Load more 12 postings Showing 12 of 12 jobs (no Load more)
Details arrive in the order 47003, 47005, 47002, 47004, 47001:
the list still reads 47001, 47002, 47003, 47004, 47005
PAGE_SIZE (12 ids → 5, 5, 2).url (for example, ones that only have text on Hacker News) still need a working link.The tests replace window.fetch with a fake API that serves 12 made-up postings, then click your buttons and read the screen like a user would. You don’t need test ids, specific class names, or an exact HTML structure. Request the URLs exactly as listed above with fetch. The tests check that:
Loading jobs… (any text containing “loading”) is visible before the first page arrives and gone after it.<a> whose href is the posting’s url, or the Hacker News item URL when url is missing.by {by} and the YYYY-MM-DD date appear for each posting.jobstories.json is requested once, and an item is requested only when its page is loaded.Showing X of Y jobs is correct after each page.Could not load jobs and a clickable Try again button appear, and clicking it loads the first page.Capitalization and extra spacing don’t matter.