Statement
medium
API pagination
`collect_items(client)` collects all items page by page.
Client: `get("/items", params={"page": n})` → a response with `status_code` and
`json()`. The body holds `{"items": [...], "has_next": bool}`.
Write tests with a fake client: several pages, one page, a 500 error. Check the
order of the items and the page numbers that were requested.
AI mentor
The AI mentor is available after you log in: it sees your attempt history and does not spend resources on anonymous requests.
Log in and ask
Hints
1 of 3 unlocked · attempts: 0
Hint 1
What should stop the loop: an empty list or the `has_next` flag? These are
different conditions, and on the last page they diverge.
Hint 2 — unlocks after 1 attempt
Hint 3 — unlocks after 3 attempts