-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
36 lines (33 loc) · 1.18 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pokémon API Demo</title>
</head>
<body>
<h1>Pokémon API Demo</h1>
<button onclick="getRandomPokemon()">Get Random Pokémon</button>
<div id="pokemonInfo">
<!-- Pokémon information will be displayed here -->
</div>
<script>
function getRandomPokemon() {
// Send a GET request to your API endpoint to get a random Pokémon
fetch('http://localhost:3000/api/pokemon/name/Bulbasaur')
.then(response => response.json())
.then(data => {
// Display the Pokémon information on the page
document.getElementById('pokemonInfo').innerHTML = `
<h2>${data.name}</h2>
<p>Type: ${data.type.join(', ')}</p>
<p>Abilities: ${data.abilities.join(', ')}</p>
`;
})
.catch(error => {
console.error('Error fetching data:', error);
});
}
</script>
</body>
</html>