Merge branch 'dev' into films
This commit is contained in:
commit
951d701a8e
17 changed files with 15772 additions and 15813 deletions
7
scripts/planets.js
Normal file
7
scripts/planets.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { api_call } from "./util";
|
||||
|
||||
console.log('planet.js loaded');
|
||||
|
||||
api_call("planets", console.log);
|
||||
|
||||
|
||||
|
|
@ -7,7 +7,7 @@ const URL = "https://swapi.dev/api";
|
|||
* @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) => {
|
||||
export const api_call = (endpoint, callback) => {
|
||||
fetch(`${URL}/${endpoint}`)
|
||||
.then(response => {
|
||||
return response.json();
|
||||
|
|
@ -15,4 +15,5 @@ const api_call = (endpoint, callback) => {
|
|||
.then(jsonResp => {
|
||||
callback(jsonResp);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue