Fix API response format compatibility on main page
The streams API now returns standardized format { success: true, data: [...] } but the frontend was still expecting the old direct array format. Added backward compatibility to handle both response formats: - New format: { success: true, data: streams } - Old format: streams (direct array) 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
8d3a6381cb
commit
cbf8cd6516
1 changed files with 3 additions and 1 deletions
|
@ -80,7 +80,9 @@ export default function Home() {
|
||||||
activeRes.json()
|
activeRes.json()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
setStreams(streamsData);
|
// Handle both old and new API response formats
|
||||||
|
const streams = streamsData.success ? streamsData.data : streamsData;
|
||||||
|
setStreams(streams);
|
||||||
setActiveSources(activeData);
|
setActiveSources(activeData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching data:', error);
|
console.error('Error fetching data:', error);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue