This commit is contained in:
ISA
2025-05-28 08:04:34 +02:00
parent 97fbb6fdc1
commit 5f0133d638
107 changed files with 1446 additions and 454 deletions

View File

@@ -1,6 +1,46 @@
# fetchWithTimeout
<!-- /docs/services/utils/fetchWithTimeout.md -->
Hilfsfunktion für Fetch mit Abbruch bei Timeout.
# ⏱️ fetchWithTimeout.js
- Parameter: URL, Optionen, Timeout (default: 5000ms)
- Nutzt `AbortController`
Hilfsfunktion zur Durchführung eines `fetch`-Requests mit einem Timeout.
---
## 💡 Zweck
Manche Serveranfragen können hängen bleiben. Diese Funktion sorgt dafür, dass eine Anfrage nach einer bestimmten Zeit abgebrochen wird, um UI-Blockierungen oder lange Wartezeiten zu vermeiden.
---
## 🧩 Funktion
```js
fetchWithTimeout(url, options, timeout);
```
- `url`: Ziel-URL
- `options`: Fetch-Optionen (Headers, Methode etc.)
- `timeout`: Zeit in Millisekunden (Standard: 5000ms)
---
## Beispiel
```js
const response = await fetchWithTimeout("/api/data", {}, 3000);
```
---
## Verhalten
- Verwendet `AbortController` zur Abbruchsteuerung
- Gibt den `fetch`-Response oder einen Fehler zurück
---
## Pfad
```
/services/utils/fetchWithTimeout.js
```