Skip to content

Instantly share code, notes, and snippets.

@godswillumukoro
Created December 1, 2022 15:00
Show Gist options
  • Save godswillumukoro/d6259b134b627dfa9a18098dbcdc7460 to your computer and use it in GitHub Desktop.
Save godswillumukoro/d6259b134b627dfa9a18098dbcdc7460 to your computer and use it in GitHub Desktop.
<!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