From 1a85f0ae36b9dd3625136866af232c8f51ff06a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reinhard=20X=2E=20F=C3=BCrst?= Date: Sun, 10 May 2026 15:32:13 +0200 Subject: [PATCH] wetter: fetch real data from weather station API --- app/api/wetter/route.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/api/wetter/route.ts b/app/api/wetter/route.ts index 21fe0e3..e454279 100644 --- a/app/api/wetter/route.ts +++ b/app/api/wetter/route.ts @@ -4,8 +4,13 @@ import { getSession } from '@/lib/session'; export async function GET() { const session = await getSession(); if (!session) return NextResponse.json({ error: 'Nicht angemeldet' }, { status: 401 }); - const temp = Math.round((8 + Math.random() * 15) * 10) / 10; - const feuchte = Math.round((40 + Math.random() * 50) * 10) / 10; - const druck = Math.round((990 + Math.random() * 30) * 10) / 10; + + const res = await fetch('https://stwwetter.fuerst-stuttgart.de/api/weather/latest', { cache: 'no-store' }); + if (!res.ok) return NextResponse.json({ error: 'Wetterdaten nicht verfügbar' }, { status: 502 }); + + const data = await res.json(); + const temp = Math.round(data.temperature * 10) / 10; + const feuchte = Math.round(data.humidity); + const druck = Math.round(data.pressure); return NextResponse.json({ temp, feuchte, druck }); }