Fetching Data

Here is an example of making an external API call

bulbasaur

ivysaur

venusaur

charmander

charmeleon

//src/pages/experiments/data-fetching.astro
---
import BaseLayout from '../../layouts/BaseLayout.astro';

const allPokemonResponse = await fetch(`https://pokeapi.co/api/v2/pokemon?limit=15`);
const allPokemonResult = await allPokemonResponse.json();
const allPokemon = allPokemonResult.results;
---
<BaseLayout title="Data Fetching" >
    <h1>Fetching data from an API call</h1>
    <h3>Fetch is in the frontmatter</h3>
    {allPokemon.map((pokemon) => (<p>{pokemon.name}</p>))}
</BaseLayout>