// api.js // API fetch logic /** * Fetch a Pokémon by name from the PokéAPI * @param {string} name * @returns {Promise} Pokémon data */ export async function fetchPokemon(name) { const res = await fetch(`https://pokeapi.co/api/v2/pokemon/${encodeURIComponent(name.toLowerCase())}`); if (!res.ok) { throw new Error('Pokémon not found'); } return await res.json(); }