Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/utils/apiFetch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Title
Add centralized API fetch wrapper with error handling

## Description
### What was changed
Introduced a small `apiFetch` utility that wraps `fetch` and provides consistent JSON parsing and error handling across the app.

### Why it was changed
Direct `fetch` usage scattered across components can lead to duplicated logic and inconsistent error handling. A centralized wrapper improves maintainability and debugging.

### How to test
1. Replace an existing `fetch` call with `apiFetch`.
2. Trigger a successful request and confirm data is returned.
3. Trigger a failing request (non-2xx response) and confirm a descriptive error is thrown.