solarData = {
const proxyUrl = "https://proxyme.glitch.me/proxy?url=";
const targetUrl = "https://api.energy-charts.info/solar_share_daily_avg?country=de";
const url = proxyUrl + encodeURIComponent(targetUrl);
return fetch(url, { headers: { accept: "application/json" } })
.then(response => {
if (!response.ok) throw new Error(`network error: ${response.statusText}`);
return response.json();
})
.then(data => {
return data.days.map((d, i) => ({
date: new Date(d.split('.').reverse().join('-')),
value: data.data[i]
}));
})
.catch(error => {
console.error("Error fetching data:", error);
return [];
});
}