Advertisement
fcamuso

Javascript Lezione 70

Aug 20th, 2022
1,138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.   <meta charset="UTF-8">
  5.   <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.   <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.   <title>Async 01</title>
  8. </head>
  9. <body>
  10.  
  11.   <div id="animeCard" style="text-align: center; color: red;">
  12.     <h3 id="titolo"> </h3>
  13.     <img src="" id="cover" width="200px" height="300px">
  14.   </div>
  15.  
  16.  
  17.  
  18.   <script>
  19.    
  20.     const una_promise =
  21.       fetch('https://anime-facts-rest-api.herokuapp.com/api/v1')
  22.         .then( (rispostaServer) => rispostaServer.json() )
  23.         .then( (datiRicevuti) =>
  24.           {
  25.             document.getElementById('titolo').textContent = datiRicevuti.data[0].anime_name;
  26.             document.getElementById('cover').src = datiRicevuti.data[0].anime_img;
  27.           }
  28.         );
  29.    
  30.     console.log(una_promise);
  31.    
  32.   </script>
  33. </body>
  34. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement