Open Indok93 opened 1 year ago
const apiUrl = "https://api.open-meteo.com/v1/forecast?latitude=57.048&longitude=9.9187&hourly=temperature_2m,relativehumidity_2m,rain,weathercode,cloudcover,visibility,windspeed_10m,winddirection_10m,is_day&daily=weathercode,temperature_2m_max,sunrise,sunset&timezone=Europe%2FBerlin"; fetch(apiUrl) .then((response) => { if (response.status !== 200) { console.error("Fejl ved hentning af data:", response.statusText); return; }
return response.json(); }) .then((data) => { console.log("API-data:", data);
console.log("Temperatur i 2m:", data.hourly.temperature_2m); console.log("Nedbør:", data.hourly.rain); console.log("Visibility:", data.hourly.visibility); console.log("Humidity:", data.hourly.relativehumidity_2m); console.log("Wind Speeds:", data.hourly.windspeed_10m); console.log("Wind direction:", data.hourly.winddirection_10m); console.log("cloud cover:", data.hourly.cloudcover); console.log("weather code:", data.hourly.weathercode); }) .catch((error) => { console.error("Der opstod en fejl under anmodningen:", error); });
const apiUrl = "https://api.open-meteo.com/v1/forecast?latitude=57.048&longitude=9.9187&hourly=temperature_2m,relativehumidity_2m,rain,weathercode,cloudcover,visibility,windspeed_10m,winddirection_10m,is_day&daily=weathercode,temperature_2m_max,sunrise,sunset&timezone=Europe%2FBerlin"; fetch(apiUrl) .then((response) => { if (response.status !== 200) { console.error("Fejl ved hentning af data:", response.statusText); return; }
return response.json(); }) .then((data) => { console.log("API-data:", data);
console.log("Temperatur i 2m:", data.hourly.temperature_2m); console.log("Nedbør:", data.hourly.rain); console.log("Visibility:", data.hourly.visibility); console.log("Humidity:", data.hourly.relativehumidity_2m); console.log("Wind Speeds:", data.hourly.windspeed_10m); console.log("Wind direction:", data.hourly.winddirection_10m); console.log("cloud cover:", data.hourly.cloudcover); console.log("weather code:", data.hourly.weathercode); }) .catch((error) => { console.error("Der opstod en fejl under anmodningen:", error); });