This commit is contained in:
Blandine Bajard 2021-10-20 11:57:27 +02:00
parent 8793fd5c0c
commit 28e38a479e
3 changed files with 14 additions and 3 deletions

View File

@ -23,7 +23,7 @@
</section> </section>
<section id="recherche"> <section id="recherche">
<form action="" id="formRecherche" onSubmit="event.preventDefault(); console.log('click')"> <form action="" id="formRecherche" onSubmit="envoiForm(event); console.log('click')">
<label for="textRecherche">Recherche : </label> <label for="textRecherche">Recherche : </label>
<input type="text" name="textRecherche" id="textRecherche"> <input type="text" name="textRecherche" id="textRecherche">
<input type="submit" value="ok"> <input type="submit" value="ok">

View File

@ -1,7 +1,9 @@
import { api_call } from './util'; import { api_call } from './util';
const films = document.getElementById("resultats"); const films = document.getElementById("resultats");
const search = document.getElementById('recherche');
const API_SEARCH = "https://swapi.dev/api/films/?search"
const API_URL = "https://swapi.dev/api/films/"; // déclare la localisation de la liste des films const API_URL = "https://swapi.dev/api/films/"; // déclare la localisation de la liste des films
function remplissage(EPISODES){ function remplissage(EPISODES){
@ -27,5 +29,13 @@ function remplissage(EPISODES){
}) })
} }
function envoiForm(event){
event.preventDefault();
api_call(API_SEARCH+search, remplissage)
console.log(formenvoyé);
}
api_call(API_URL, remplissage); api_call(API_URL, remplissage);

View File

@ -86,10 +86,11 @@ console.log('personnage.js loaded');
</div> </div>
</section>`; </section>`;
}
//Pagination //Pagination
createPagination(previousUrl, nextUrl, PERSONNAGES, remplissage); createPagination(previousUrl, nextUrl, PERSONNAGES, remplissage);
} }
api_call(API_URL + "/people", remplissage); api_call(API_URL + "/people", remplissage);
console.log('personnage.js loaded'); console.log('personnage.js loaded');