noch Fehler für Charts
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// /components/modules/kue705FO/charts/LoopMeasurementChart/LoopChartActionBar.tsx
|
||||
// components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx
|
||||
import React, { useState } from "react";
|
||||
import DateRangePicker from "../DateRangePicker";
|
||||
import LoopMeasurementChart from "./LoopMeasurementChart";
|
||||
@@ -7,20 +7,26 @@ import { setChartData } from "../../../../../../redux/slices/chartDataSlice";
|
||||
|
||||
const LoopChartActionBar: React.FC = () => {
|
||||
const dispatch = useDispatch();
|
||||
const BASE_URL = "http://localhost:3002";
|
||||
|
||||
const [showChart, setShowChart] = useState(false);
|
||||
|
||||
const handleFetchData = async () => {
|
||||
try {
|
||||
const response = await fetch(`${BASE_URL}/loop`);
|
||||
if (!response.ok) throw new Error("Fehler beim Abrufen der Daten");
|
||||
|
||||
const response = await fetch("/mockData.json");
|
||||
const data = await response.json();
|
||||
if (Array.isArray(data)) {
|
||||
// data ist ein Array und kann mit .map() verwendet werden
|
||||
console.log("Daten geladen:", data);
|
||||
} else {
|
||||
console.error("Erwartetes Array, aber erhalten:", data);
|
||||
}
|
||||
dispatch(setChartData(data));
|
||||
setShowChart(true);
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Laden der Daten:", error);
|
||||
if (error instanceof Response) {
|
||||
const errorMessage = await error.text();
|
||||
console.error("Fehlermeldung vom Server:", errorMessage);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user