The market is outdoors. Add a strip above the vendors: the temperature, the chance of rain and the wind for the evening (the market runs 19:00–01:00, so the hours 19:00 to 00:00), from Open-Meteo, a public weather API that needs no key and sends CORS headers. Different server, different shape of data, same rules. ★★☆
“Do I need a jacket? Does the market close if it rains?”
You'll demo (next class): the strip with six hourly columns, 19:00 to 00:00. Reload: no request, it came from the cache. Turn off Wi-Fi (or DevTools → Offline) with an empty cache: the strip says the forecast isn't available, and the vendors still load.
Four things, on top of your connected market. They count when they work with chaos on (control page).
GET to Open-Meteo for Moll de la Fusta: temperature and precipitation probability, hourly, Europe/Madrid.What has to work for the demo next class, not how. The core above is part of it.
GET to Open-Meteo for Moll de la Fusta (latitude 41.38, longitude 2.18), hourly temperature, precipitation probability and wind, time zone Europe/Madrid.localStorage with the time it was fetched; reused for 30 minutes.GET /api/stalls start together; each renders its part as soon as it has it.New tool: Open-Meteo answers with parallel arrays: hourly.time[i], hourly.temperature_2m[i]… Index i is the same hour in every array. Its docs page builds the URL for you.
New tool: Starting two requests without waiting for each other: call two async functions without awaiting the first before starting the second. await Promise.all([…]) waits for both: right when you need both values together, wrong when the vendors shouldn't wait for the weather.
{ into the cache entry by hand (Application panel), reload.weather_code field (WMO codes).Network panel first: is the request sent, with what, and what came back? Then a hint.
The response has one array of times and one of temperatures. How do you turn them into one array of hours?
Cache: what do you store besides the data, so you can tell later whether it's too old?
await, await: does the second request start before the first one ends? Does the vendor list have to wait for anything but its own response?
This brief assumes Connect the market is done: api.js works, the stalls come from the API, loading and errors are handled. Then: The Open-Meteo request is in the Network panel with a 200, and hourly.temperature_2m is in the console.