---
// src/pages/index.astro
const response = await fetch('https://jsonplaceholder.typicode.com/posts?_limit=5');
const posts = await response.json();
---
{posts.map((post) => - {post.title}
)}
Steps to confirm the data is frozen at build time:
1. Run npm run build and npm run preview, then load the page and
note the five titles rendered.
2. Without changing anything in this file, reload the page in the
browser several times. The same five titles appear every time -
nothing re-fetches on page load, because this is a static file
served from dist/, not a live request.
3. Run npm run build again. The frontmatter's fetch() call runs a
second time, at that new build, and if the placeholder API's own
data had changed in the meantime, the newly built output would
reflect it - but only after this fresh build, never on an ordinary
page load in between.
Notes:
- This is the concrete, observable proof of Chapter 2's own finding
applied to a network request: the frontmatter runs once, at build
time, and never again until the next build.