From 818c34165c9e67284784f7734f5d8db16ceb3cc5 Mon Sep 17 00:00:00 2001 From: Vincent Ramiere Date: Mon, 18 Oct 2021 13:04:33 +0200 Subject: [PATCH] ajout du bouton retour --- index.html | 1 + script.js | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/index.html b/index.html index c27c349..9b9602f 100644 --- a/index.html +++ b/index.html @@ -21,6 +21,7 @@
+ \ No newline at end of file diff --git a/script.js b/script.js index 555f700..b31b54c 100644 --- a/script.js +++ b/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 +=` +
+ Photo d'identité +

${PERSONNE.last_name} ${PERSONNE.first_name}

+ +

${PERSONNE.id}

+ +
+` +} + +} +) + + } )