Weer erbij!

This commit is contained in:
Atilla
2024-04-02 11:35:43 +02:00
parent 6f391d01f6
commit 417dacbe73
2 changed files with 52 additions and 54 deletions

View File

@@ -155,4 +155,29 @@ function updateBatteryData(batteryData)
document.getElementById('tevredenheid-256').innerHTML = batteryData[0].last_battery_voltage;
}
console.log(batteryData);
}
}
const apiKey = "9516081f15727d063c9e2f08454a2fe9";
const city = "Leiden";
// Maak de URL voor de API-aanroep
const apiUrl = `https://weerlive.nl/api/weerlive_api_v2.php?key=${apiKey}&locatie=${city}`;
// Doe een GET-verzoek naar de API
fetch(apiUrl)
.then(response => {
if (response.ok) {
return response.json();
}
throw new Error('Network response was not ok.');
})
.then(data => {
// Verwerk de ontvangen weerdata
console.log(data);
const weatherIcon = data.live_weather.image;
const weatherImageUrl = `https://www.weerlive.nl/delen.php?size=klein&weer=${weatherIcon}`;
document.getElementById('weatherImage').src = weatherImageUrl;
})
.catch(error => {
console.error('There was a problem with the fetch operation:', error);
});