# 🌐 fetchLocationDevices Diese Funktion lädt alle Geräte für einen bestimmten Standort aus der Datenbank via API-Endpunkt. --- ## 📍 Pfad ``` /redux/api/fromDB/fetchLocationDevices.js ``` --- ## 📥 Funktion ```ts export const fetchLocationDevices = async () => { const response = await fetch("/api/talas_v5_DB/locationDevice/locationDevices"); if (!response.ok) { throw new Error("Geräteliste konnte nicht geladen werden"); } return await response.json(); }; ``` --- ## 📡 API-Endpunkt ```http GET /api/talas_v5_DB/locationDevice/locationDevices ``` Dieser Endpunkt liefert eine JSON-Liste aller Geräte eines Standorts (z. B. für Map-Rendering, POI-Anzeige, Standortübersicht etc.). --- ## 🧪 Fehlerbehandlung Falls der Request fehlschlägt (z. B. Statuscode ≠ 2xx), wird folgender Fehler ausgelöst: ``` "Geräteliste konnte nicht geladen werden" ``` Dies kann im Redux-Slice über den `.rejected`-Case ausgewertet werden. --- ## 🧩 Verwendung ```ts import { fetchLocationDevices } from "@/redux/api/fromDB/fetchLocationDevices"; const result = await fetchLocationDevices(); console.log(result); // Erwartet: Array von Geräteobjekten ``` Diese Funktion wird typischerweise im Redux-Thunk `fetchLocationDevicesFromDB` verwendet: ```ts const data = await fetchLocationDevices(); ``` --- ## 🔄 Zusammenhang - Eingebunden in: [`locationDevicesFromDBSlice.js`](./locationDevicesFromDBSlice.md) - Redux Thunk: `fetchLocationDevicesFromDB`