📦 orbitale-labs / meteo-widget Public
‹› Code🕓 6 commits

Branchement de l'API météo

P pixeldrift a commité le 28 sept. 2026
1 parent 1d315db · commit a8e7a2aa0e98b6c3d552e32be75046bce3db2d92
src/config.js+3 −0
……@@ -0,0 +1,3 @@
1+ // Clé du service météo (compte de test)
2+ export const METEO_API_KEY = "mtw_test_4f9a1c7e2b8d5a03";
3+ export const METEO_URL = "https://api.meteo-service.example/v1/current";
src/widget.js+4 −1
……@@ -1,10 +1,13 @@
11 // Widget météo Orbitale
2+ import { METEO_API_KEY, METEO_URL } from "./config.js";
3+
24 export async function renderWidget(el, city) {
35 el.textContent = `Météo de ${city} : chargement…`;
46 const data = await fetchWeather(city);
57 el.textContent = `${city} : ${Math.round(data.temp)} °C`;
68 }
79
810 async function fetchWeather(city) {
11+ const res = await fetch(`${METEO_URL}?city=${encodeURIComponent(city)}&key=${METEO_API_KEY}`);
12+ return res.json();
9- return { temp: 18 }; // valeur fixe en attendant l'API
1013 }