Files
nodeMap/docs/services/utils/fetchWithTimeout.md

52 lines
900 B
Markdown
Raw Permalink 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.

<!-- /docs/services/utils/fetchWithTimeout.md -->
# ⏱️ fetchWithTimeout.js
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
```
---
[Zurück zur Übersicht](../../README.md)