reorg de simages, ajout d'un catch dans api_call()
This commit is contained in:
parent
05a642a78b
commit
8bb642383d
14 changed files with 7289 additions and 82 deletions
|
|
@ -3,7 +3,7 @@ console.log("util.js loaded");
|
|||
const URL = "https://swapi.dev/api";
|
||||
|
||||
/**
|
||||
* Envoie un GET à l'api swappi
|
||||
* Envoie une requête 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
|
||||
*/
|
||||
|
|
@ -14,6 +14,10 @@ export const api_call = (endpoint, callback) => {
|
|||
})
|
||||
.then(jsonResp => {
|
||||
callback(jsonResp);
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(`Erreur lors de l'appel API :
|
||||
${error.message}`);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue