From 423897d1bfe3f860ee4193d02853a7b42a6bcbc4 Mon Sep 17 00:00:00 2001 From: Decobus Date: Tue, 22 Jul 2025 14:49:55 -0400 Subject: [PATCH] Fix API response handling on main page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Handle new standardized API response format for streams endpoint - Extract data from { success: true, data: [...] } wrapper - Maintain backward compatibility with old API format - Fixes TypeError: streams.forEach is not a function 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- app/page.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/page.tsx b/app/page.tsx index 0e3ff66..e90a6a5 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -80,8 +80,12 @@ export default function Home() { activeRes.json() ]); - setStreams(streamsData); - setActiveSources(activeData); + // Handle both old and new API response formats + const streams = streamsData.success ? streamsData.data : streamsData; + const activeSources = activeData.success ? activeData.data : activeData; + + setStreams(streams); + setActiveSources(activeSources); } catch (error) { console.error('Error fetching data:', error); showError('Failed to Load Data', 'Could not fetch streams. Please refresh the page.');