ajout du bouton retour
This commit is contained in:
parent
65b09bf029
commit
818c34165c
|
@ -21,6 +21,7 @@
|
|||
<div id="personne"></div>
|
||||
</section>
|
||||
|
||||
<button id = "page1">page precedente</button>
|
||||
<button id = "page2">page suivante</button>
|
||||
</body>
|
||||
</html>
|
34
script.js
34
script.js
|
@ -5,6 +5,7 @@ const EMAIL = document.getElementsByClassName('email');
|
|||
const AVATAR = document.getElementsByClassName('avatar');*/
|
||||
const MEMBER = document.getElementById('personne');
|
||||
const BUTTON = document.getElementById('page2');
|
||||
const BUTTON1 = document.getElementById('page1')
|
||||
|
||||
console.log(MEMBER);
|
||||
const API_URL = "https://reqres.in/api/users?page=1";
|
||||
|
@ -67,6 +68,39 @@ fetch(API_URL)
|
|||
})
|
||||
|
||||
|
||||
}
|
||||
)
|
||||
|
||||
BUTTON1.addEventListener('click', ()=>{
|
||||
const API_PAGE1 = "https://reqres.in/api/users?page=1";
|
||||
fetch(API_PAGE1)
|
||||
.then((response1) => {
|
||||
console.log(response1);
|
||||
return response1.json()
|
||||
})
|
||||
.then(responsFormat1 => {
|
||||
console.log(responsFormat1);
|
||||
MEMBER.innerHTML = " ";
|
||||
for(let index = 0; index <6; index++){
|
||||
console.log(responsFormat1.data[index]);
|
||||
const PERSONNE = responsFormat1.data[index];
|
||||
console.log(PERSONNE);
|
||||
|
||||
MEMBER.innerHTML +=`
|
||||
<div class="fiche">
|
||||
<img src="${PERSONNE.avatar}" alt="Photo d'identité">
|
||||
<p class= "nom">${PERSONNE.last_name} ${PERSONNE.first_name}</p>
|
||||
<!--<p class="prenom">${PERSONNE.first_name}</p>-->
|
||||
<p class="identifiant">${PERSONNE.id}</p>
|
||||
<p class="email">${PERSONNE.email}</p>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue