A small catalog needs an encoded search box. The preview is intentionally powered by an explicit in-page mock fetch, so it works offline and never claims to show live data.
The seed search showed why a raw & breaks hand-built query strings. The catalog fixture in this lesson reads the q parameter back from your URL; an incorrectly encoded term loses part of its value. Its data stays local, and mockFetch never reaches the network.
For another setting, a gallery could form its request like this:
async function findPaintings(term) {
const params = new URLSearchParams({ q: term });
const response = await mockFetch(`/api/paintings?${params}`);
return response.json();
}
The catalog starts with a search field and no results. Search tea & honey to see a single result, then search an unmatched term to see an empty message. Check the visible request URL: %26 encodes the ampersand, while textContent protects any resulting title in the list. Avoid treating URL encoding as permission to put server text into innerHTML.
#catalog-form from navigating on submit.q with URLSearchParams in a /api/catalog request and display that URL in #request-url.#results with matching product names as literal list-item text.No matches. in #search-status.