Archi de base

This commit is contained in:
William Noris 2021-10-18 15:24:38 +02:00
parent 5252705940
commit 966604bb1f
15 changed files with 77621 additions and 0 deletions

18
scripts/util.js Normal file
View file

@ -0,0 +1,18 @@
console.log("util.js loaded");
const URL = "https://swapi.dev/api";
/**
* Envoie un GET à l'api swappi
* @param {string} endpoint l'endpoint à interroger (ex: planets)
* @param {function} callback La fonction qui traitera la réponse JSON en retour
*/
const api_call = (endpoint, callback) => {
fetch(`${URL}/${endpoint}`)
.then(response => {
return response.json();
})
.then(jsonResp => {
callback(jsonResp);
});
}