Building a Fetching App
Setup
npm create vite
name: pokedex
Vanilla
JavaScript
cd into pokedex and npm i
Plan
draw a wireframe
plan out the logic:
When the page loads:
fetch Pikachu (make sure to catch any errors)
render Pikachu data to the screen
add an event listener for the form
When the form is submitted:
grab data from the form
use that data to fetch a new pokemon (make sure to catch any errors)
render that pokemon to the screen
HTML
Within the body of our index.html file, we'll provide the structure for our application's front end
JavaScript
First, render Pikachu data when the page loads. Here we use a helper function that can fetch and render any pokemon. The flexibility of this generic helper function will be useful for the search functionality.
Next, we implement the form search such that it can also fetch pokemon data. Make sure to use the getPokemonData helper from the last step!
Last updated