Rendering a list from an API

You have the three pieces. A place to put things (the DOM), a way to get data (fetch), and a way to build nodes from data (createElement). Now compose them end to end and watch the browser render a real book list from a real JSON file.

Real UIs always have at least three states for any async operation: loading, success, and error. Your UI should show a spinner while the fetch is in flight, a list when it succeeds, and a readable message when it fails. Forgetting any of these is the most common beginner bug in every framework.

Validation checklist: Run the vanilla catalog

Loading practice…

Checkpoint: DOM and data checkpoint

Loading practice…

Now that you can fetch data and render it, the next step is handling what happens while the data is in flight and when things go wrong. Next up: loading states, error handling, and the race conditions that bite when clicks arrive faster than responses.