Created
December 1, 2022 15:00
-
-
Save godswillumukoro/d6259b134b627dfa9a18098dbcdc7460 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Pokemon</title> | |
</head> | |
<body> | |
<h1>Pokemon API</h1> | |
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> | |
<script> | |
// const axios = require('axios') | |
let pokemon = [] | |
const loadPokemon = async () => { | |
try { | |
const {data} = await axios('https://pokeapi.co/api/v2/pokemon?limit=5') | |
pokemon = data.results | |
} catch(err) { | |
console.error(err) | |
} | |
} | |
await loadPokemon() | |
console.log(pokemon) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment