javascript import fix

This commit is contained in:
William Noris 2021-10-18 17:32:20 +02:00
parent 6a9f0e0968
commit 0cfd054680
12 changed files with 31524 additions and 4 deletions

7
scripts/planets.js Normal file
View file

@ -0,0 +1,7 @@
import { api_call } from "./util";
console.log('planet.js loaded');
api_call("planets", console.log);

View file

@ -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);
});
}
}