mise en page

This commit is contained in:
Vincent Ramiere 2021-10-18 12:01:54 +02:00
commit 2df1ec3110
2 changed files with 35 additions and 2 deletions

View File

@ -20,5 +20,7 @@
<div id="personne"></div> <div id="personne"></div>
</section> </section>
<button id = "page2">page suivante </button>
</body> </body>
</html> </html>

View File

@ -4,10 +4,13 @@ const IDENTIFIANT = document.getElementsByClassName('identifiant');
const EMAIL = document.getElementsByClassName('email'); const EMAIL = document.getElementsByClassName('email');
const AVATAR = document.getElementsByClassName('avatar');*/ const AVATAR = document.getElementsByClassName('avatar');*/
const MEMBER = document.getElementById('personne'); const MEMBER = document.getElementById('personne');
<<<<<<< HEAD
console.log(MEMBER); console.log(MEMBER);
=======
const BUTTON = document.getElementById ('page2');
>>>>>>> c7bfce2711271bd6a05a3de8ee1bef5309fb0f4e
const API_URL = "https://reqres.in/api/users?page=1"; const API_URL = "https://reqres.in/api/users?page=1";
fetch(API_URL) fetch(API_URL)
.then((response) => { .then((response) => {
console.log(response); console.log(response);
@ -38,6 +41,33 @@ fetch(API_URL)
} }
BUTTON.addEventListener('click', ()=>{
const API_PAGE2 = "https://reqres.in/api/users?page=2";
fetch(API_PAGE2)
.then((response2) => {
console.log(response2);
return response2.json()
})
.then(responsFormat2 => {
console.log(responsFormat2);
for(let index = 0; index <6; index++){
console.log(responsFormat2.data[index]);
const PERSONNE = responsFormat2.data[index];
console.log(PERSONNE);
MEMBER.innerHTML +=`
<div>
<p>${PERSONNE.last_name}</p>
<p>${PERSONNE.first_name}</p>
<p>${PERSONNE.id}</p>
<p>${PERSONNE.email}</p>
<img src="${PERSONNE.avatar}" alt="">
</div>
`
}
})
} }
) )
@ -46,4 +76,5 @@ fetch(API_URL)
.catch(err => { .catch(err => {
console.error(err); console.error(err);
})
}); });