Every card gets a Reviews button. It opens a dialog with that stall's reviews, newest first, and a form to add one. The server validates; the dialog shows what it says. ★☆☆
“Four and a half stars from two people. Who are they, and what did they eat?”
You'll demo (next class): open Taco Bike's reviews, post one, see it at the top with the server's id. Post one that's too short: the message appears under the text field and nothing you typed is lost. Delete the review you just wrote.
Four things, on top of your connected market. They count when they work with chaos on (control page).
<dialog> with that stall's reviews (GET), with a loading and an error state.POSTs a review; on 201 the server's review appears at the top.What has to work for the demo next class, not how. The core above is part of it.
GET /api/stalls/:id/reviews when the dialog opens, for the stall that was clicked.POST a review as JSON; rating is a number.DELETE /api/reviews/:id for reviews posted from this browser (remember their ids). The server doesn't check ownership (a course simplification): a real API would, because a client-side rule is no rule.aria-invalid on the input.New tool: <dialog> and showModal(): a modal with focus handling and Esc built in.
| Method | Path | Answers |
|---|---|---|
GET | /api/stalls/:id/reviews | 200 · array, newest first · 404 |
POST | /api/stalls/:id/reviews | 201 + Location · 400 · 415 · 422 { fields } · 404 |
DELETE | /api/reviews/:id | 204 · 404 |
GET | /api/stalls/:id | 200 · the stall with a fresh rating and reviewCount |
<img src=x onerror=alert(1)>.Intl.RelativeTimeFormat.minlength), and keep the server's messages anyway.Network panel first: is the request sent, with what, and what came back? Then a hint.
Where does the dialog find out which stall it's for? The click happened on a card that render() may have replaced since.
After a POST, which number on the card is now wrong, and who knows the right value?
Two requests for two different stalls are in flight. The slower one arrives last. What does the dialog show?
This brief assumes Connect the market is done: api.js works, the stalls come from the API, loading and errors are handled. Then: Click a card's button: GET …/reviews appears in the Network panel with a 200, and the JSON is in the console.