Fix API response handling on main page

- 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 <noreply@anthropic.com>
This commit is contained in:
Decobus 2025-07-22 14:49:55 -04:00
parent ec6ff1b570
commit 423897d1bf

View file

@ -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.');