Fetching APIs in frontmatter
📖 Scenario: You are building a simple Astro website that shows a list of users fetched from an external API. You want to load this data in the frontmatter of your Astro component so it is ready when the page renders.
🎯 Goal: Create an Astro component that fetches user data from a public API in the frontmatter and displays the users' names in a list on the page.
📋 What You'll Learn
Use Astro frontmatter to fetch data from the API
Store the fetched data in a variable called
usersRender a list of user names inside a
<ul> elementUse semantic HTML and accessible markup
💡 Why This Matters
🌍 Real World
Fetching data from APIs in frontmatter is common in Astro to prepare data before rendering pages, improving performance and SEO.
💼 Career
Understanding how to fetch and use API data in Astro components is essential for frontend developers working with modern static site generators and frameworks.
Progress0 / 4 steps