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:
parent
ec6ff1b570
commit
423897d1bf
1 changed files with 6 additions and 2 deletions
|
@ -80,8 +80,12 @@ export default function Home() {
|
||||||
activeRes.json()
|
activeRes.json()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
setStreams(streamsData);
|
// Handle both old and new API response formats
|
||||||
setActiveSources(activeData);
|
const streams = streamsData.success ? streamsData.data : streamsData;
|
||||||
|
const activeSources = activeData.success ? activeData.data : activeData;
|
||||||
|
|
||||||
|
setStreams(streams);
|
||||||
|
setActiveSources(activeSources);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching data:', error);
|
console.error('Error fetching data:', error);
|
||||||
showError('Failed to Load Data', 'Could not fetch streams. Please refresh the page.');
|
showError('Failed to Load Data', 'Could not fetch streams. Please refresh the page.');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue