diff --git a/assets/js/services/ApiService.js b/assets/js/services/ApiService.js index 15cf5220..29647432 100644 --- a/assets/js/services/ApiService.js +++ b/assets/js/services/ApiService.js @@ -1,14 +1,12 @@ import ky from "ky"; -import params from "@params"; class ApiService { #controller = null; - // Params imported from Hugo config params - // (they can be defined through environment variables) - #apiKey = params.api.key; - #baseURL = params.api.baseurl; - #host = params.api.host; + // TODO import data with build : https://gohugo.io/hugo-pipes/js/#:~:text=params%20%5Bmap%20or,New%20in%20v0.78.0 + + // TODO set from .env ? + #baseURL = "https://api.ecoindex.fr/v1/"; #browserWidth = 1920; #browserHeight = 1080; @@ -87,7 +85,9 @@ class ApiService { async #fetchApi(slug, options) { this.abortAnalysis(); const controller = (this.#controller = new AbortController()); + const { signal } = controller; + const response = await ky(slug, { ...options, prefixUrl: this.#baseURL, diff --git a/config/_default/params.toml b/config/_default/params.toml index ec87b133..22244674 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -1,6 +1 @@ themeColor = "#007e5f" - -[api] - key = "3037e7e96fmsh12bedced9f019f8p1cd804jsn4967070f8bda" - baseurl = "https://ecoindex.p.rapidapi.com/v1/" - host = "ecoindex.p.rapidapi.com"