One more error handling case

This commit is contained in:
shamoon 2024-06-22 13:11:17 -07:00
parent b4a90fbf24
commit 56712e886c

View File

@ -27,6 +27,7 @@ export default function Component({ service }) {
useEffect(() => {
if (data && !data.error) {
const sensorData = data.find((item) => item.label === sensorName);
if (sensorData) {
setDataPoints((prevDataPoints) => {
const newDataPoints = [...prevDataPoints, { value: sensorData.value }];
if (newDataPoints.length > pointsLimit) {
@ -34,6 +35,9 @@ export default function Component({ service }) {
}
return newDataPoints;
});
} else {
data.error = true;
}
}
}, [data, sensorName, pointsLimit]);