This commit is contained in:
HediMjid 2021-10-19 13:54:44 +02:00
commit b6904486e8
2 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="fr">
<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>Brief Star Wars - Films</title>
<script src="./scripts/films.js" defer></script>
</head>
<body>
<h1>People</h1>
<section id="container" style="font-size:12px;">
</section>
<div class="boutons">
<button class="allButtons" name="moins" value="-1"> < </button>
<div id="buttons"></div>
<button class="allButtons" name="plus" value="+1"> > </button>
</div>
</body>
</html>

View File

@ -0,0 +1,27 @@
const FILMS = document.getElementById('container');
const API_URL = "https://swapi.dev/api/films";
fetch(API_URL)
.then((reponse) => {
//console.log(reponse);
return reponse.json()
})
.then(reponseFormat => {
for(let index = 0; index < reponseFormat.results.length; index++){
//console.log(reponseFormat.results[index]);
const data = reponseFormat.results[index];
console.log(data);
FILMS.innerHTML +=`
<p div class="films">${data.title}</p>
<p div id="episode_id">${data.episode_id}</p>
<p div id="opening_crawl">${data.opening_crawl}</p>
<p div id="director">${data.director}</p>
<p div id="producer">${data.producer}</p>
<p div id="release_date">${data.release_date}</p>
<p div id="starships">${data.starships}</p>
<p div id="species">${data.starships}</p>
<hr>`
}
})