From be28fdfb215dcdc05d9e176ef46976c82f40d90c Mon Sep 17 00:00:00 2001 From: William Noris Date: Tue, 19 Oct 2021 11:52:12 +0200 Subject: [PATCH] =?UTF-8?q?Chargement=20des=20donn=C3=A9es=20de=20l'api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/planets.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/scripts/planets.js b/scripts/planets.js index 88ed73e..8a6227c 100644 --- a/scripts/planets.js +++ b/scripts/planets.js @@ -4,9 +4,6 @@ const planetes = document.getElementById("resultats"); console.log('planet.js loaded'); -api_call(API_URL + "/planets", console.log); - - function remplissage(results){ const previousUrl = results.previous; @@ -20,9 +17,17 @@ function remplissage(results){ const terrain = resultPlanet.terrain; const population = resultPlanet.population; - // const tabResidents = resultPLanet.residents; - // const tabResidents = call_api(`people/`); - const tabFilms = resultPLanet.films; + const tabResidents = resultPLanet.residents; + //Problème de requêtes asyncrones + // let tabResidents = []; + // for(index in resultPlanet.residents){ + // api_call(resultPlanet.residents[index], (jsonresp)=>{ + // console.log(jsonresp.name); + // }); + // } + // console.log(`${nom} - résidents : ${resultPlanet.residents}`); + // console.log(`nom des résidents : ${tabResidents}`); + const tabFilms = resultPlanet.films; } @@ -38,4 +43,4 @@ function remplissage(results){ `; } -// api_call(API_URL + "/planets", remplissage); \ No newline at end of file +api_call(API_URL + "/planets", remplissage); \ No newline at end of file