diff --git a/index.html b/index.html index d7d682d..76d60d3 100644 --- a/index.html +++ b/index.html @@ -20,5 +20,7 @@
+ + \ No newline at end of file diff --git a/script.js b/script.js index 97fd18c..fe3ac8a 100644 --- a/script.js +++ b/script.js @@ -4,10 +4,9 @@ const IDENTIFIANT = document.getElementById('identifiant'); const EMAIL = document.getElementById('email'); const AVATAR = document.getElementById('avatar'); const MEMBER = document.getElementById('personne'); +const BUTTON = document.getElementById ('page2'); const API_URL = "https://reqres.in/api/users?page=1"; - - fetch(API_URL) .then((response) => { console.log(response); @@ -38,6 +37,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 +=` +
+

${PERSONNE.last_name}

+

${PERSONNE.first_name}

+

${PERSONNE.id}

+

${PERSONNE.email}

+ +
+ ` +} + + }) + } ) @@ -46,4 +72,5 @@ fetch(API_URL) .catch(err => { console.error(err); +}) }); \ No newline at end of file