Difference between revisions of "Pokemon"

From ProgZoo
Jump to navigation Jump to search
(Created page with "You can use the api provided by https://pokeapi.co/ to provide data for this appication. Create a new folder with two files: index.html <!DOCTYPE html> <html> <head>...")
 
Line 4: Line 4:


index.html
index.html
<pre>
  <!DOCTYPE html>
  <!DOCTYPE html>
  <html>
  <html>
Line 14: Line 15:
     </body>
     </body>
  </html>
  </html>
 
</pre>
pokemon.js
pokemon.js
  document.body.onload = async ()=>{
  document.body.onload = async ()=>{

Revision as of 20:09, 16 August 2022

You can use the api provided by https://pokeapi.co/ to provide data for this appication.

Create a new folder with two files:

index.html

 <!DOCTYPE html>
 <html>
    <head>
        <script src="pokemon.js" defer></script>
    </head>
    <body>
        <h1>Welcome to the Pokemon App</h1>
        <div id="detail"></div>
    </body>
 </html>

pokemon.js

document.body.onload = async ()=>{
   let resp = await fetch("https://pokeapi.co/api/v2/pokemon/?limit=30");
   let data = await resp.json();
   document.getElementById('detail').innerHTML = data;
}