Skip to content

Add centralized API fetch wrapper with error handling#1

Open
payday-sepia wants to merge 1 commit intomasterfrom
payday-sepia-patch-1
Open

Add centralized API fetch wrapper with error handling#1
payday-sepia wants to merge 1 commit intomasterfrom
payday-sepia-patch-1

Conversation

@payday-sepia
Copy link
Owner

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.

## 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant