Affiche les personnage
This commit is contained in:
parent
4ff40f5e9a
commit
deacbaacc0
|
@ -13,42 +13,42 @@ class People {
|
|||
this.mass = mass;
|
||||
this.skin_color=skin_color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
console.log('personnage.js loaded');
|
||||
|
||||
api_call(API_URL+"/people", console.log);
|
||||
//api_call(API_URL+"/people", console.log);
|
||||
|
||||
fetch(API_URL+"/people")
|
||||
.then(response => {
|
||||
return response.json();
|
||||
})
|
||||
.then(jsonResp => {
|
||||
remplissage(jsonResp);
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(`Erreur lors de l'appel API :
|
||||
${error.message}`);
|
||||
});
|
||||
|
||||
function remplissage(json){
|
||||
console.log(json.results[0]);
|
||||
|
||||
api_call(API_URL+ "/planets/1", (response) => {
|
||||
console.log(response);
|
||||
NAME.innerText = results[i];
|
||||
});
|
||||
|
||||
|
||||
personnages.innerHTML =
|
||||
`<section class="resultat">
|
||||
<h1 class="titreAccordeon"></h1>
|
||||
<div class="accordeon">
|
||||
<div class="1">
|
||||
<div id=annéeNaissance>Année de Naissance : </div>
|
||||
<div id=couleurYeux> Couleur des Yeux : </div>
|
||||
<div id=genre>Genre : </div>
|
||||
<div id=couleurCheveux> Couleur des Cheveux : </div>
|
||||
<div id= poids> Poids du personnage : kg</div>
|
||||
<div id= couleurPeau> Couleur de Peau : </div>
|
||||
<div class="2"> 2</div>
|
||||
<div class="3"> 3</div>
|
||||
</div>
|
||||
</section>`;
|
||||
}
|
||||
|
||||
PERSONNAGES.innerHTML = '';
|
||||
const PERPAGE = 10;
|
||||
|
||||
console.log(json.results[0]);
|
||||
|
||||
// api_call(API_URL+ "/planets/1", (response) => {
|
||||
// console.log(response);
|
||||
// NAME.innerText = results[i].name;
|
||||
|
||||
// });
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
PERSONNAGES.innerHTML = '';
|
||||
const PERPAGE = json.results.length;
|
||||
|
||||
console.log('coucou');
|
||||
for (let i = 0; i < PERPAGE; i++) {
|
||||
const urlbirth_year = json.results[i].birth_year;
|
||||
const urleye_colo=json.results[i].eye_colo;
|
||||
|
@ -57,9 +57,26 @@ for (let i = 0; i < PERPAGE; i++) {
|
|||
const urlheight = json.results[i].height;
|
||||
const urlmass=json.results[i].mass;
|
||||
const urlskin_color= json.results[i].skin_color;
|
||||
const urlname= json.results[i].name;
|
||||
// const gens = new People(urlbirth_year, urleye_colo, urlgender, urlhair_color, urlmass,urlskin_color);
|
||||
// console.log(gens);
|
||||
|
||||
PERSONNAGES.innerHTML +=
|
||||
`<section class="resultat">
|
||||
<h1 class="titreAccordeon">${urlname}</h1>
|
||||
<div class="accordeon">
|
||||
<div class="1">
|
||||
<div id=annéeNaissance>Année de Naissance : ${urlbirth_year} </div>
|
||||
<div id=couleurYeux> Couleur des Yeux : ${urleye_colo}</div>
|
||||
<div id=genre>Genre : ${urlgender}</div>
|
||||
<div id=couleurCheveux> Couleur des Cheveux : ${urlhair_color} </div>
|
||||
<div id= poids> Poids du personnage : ${urlmass} kg</div>
|
||||
<div id= couleurPeau> Couleur de Peau : ${urlskin_color} </div>
|
||||
<div class="2"> 2</div>
|
||||
<div class="3"> 3</div>
|
||||
</div>
|
||||
</section>`;
|
||||
|
||||
|
||||
|
||||
const gens = new Identite(urlbirth_year, urleye_colo, urlgender, urlhair_color, urlmass,urlskin_color);
|
||||
gens.PersonneSuiv();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue