mirror of
https://github.com/mblanke/Dashboard.git
synced 2026-03-01 12:10:20 -05:00
fix: extract data.devices in UnifiWidget to prevent e.filter crash
API returns {devices, health, totalClients} object, not an array.
setDevices(data) was setting the whole object, causing .filter() to crash.
This commit is contained in:
@@ -19,7 +19,9 @@ export default function UnifiWidget() {
|
||||
const response = await fetch("/api/unifi");
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
setDevices(data);
|
||||
// API returns { devices, health, totalClients } — extract the array
|
||||
const devArr = Array.isArray(data) ? data : Array.isArray(data?.devices) ? data.devices : [];
|
||||
setDevices(devArr);
|
||||
setError(false);
|
||||
} else {
|
||||
setError(true);
|
||||
|
||||
Reference in New Issue
Block a user