fetch JSON
Asks for a file or web address, waits for the reply, then turns it into data (objects and arrays). Both lines need await, inside an async function.
const response = await fetch("weather.json");
const data = await response.json();Example
<p id="out">Loading…</p>
<script>
async function load() {
const response = await fetch("weather.json");
const data = await response.json();
document.querySelector("#out").textContent = "Days: " + data.daily.time.length;
}
load();
</script>