Files
nodeMap/docs/redux/api/fromDB/fetchLocationDevices.md
ISA b847b5d2c8 docs: Projektstruktur der Dokumentation an Quellcode angepasst
- Verzeichnisstruktur unter /docs spiegelt nun die tatsächliche Projektstruktur wider
- frontend/server-Trennung entfernt zugunsten von /docs/pages, /docs/redux, /docs/utils etc.
- Erhöht Wiederauffindbarkeit, Übersichtlichkeit und Entwicklerfreundlichkeit
2025-05-27 09:30:40 +02:00

70 lines
1.5 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 🌐 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`