Skip to content

refactor: replace fetch API with axios (#157)#159

Open
prdai wants to merge 2 commits into
LDFLK:mainfrom
prdai-archive:feat/issue-157-fetch-to-axios
Open

refactor: replace fetch API with axios (#157)#159
prdai wants to merge 2 commits into
LDFLK:mainfrom
prdai-archive:feat/issue-157-fetch-to-axios

Conversation

@prdai

@prdai prdai commented May 31, 2026

Copy link
Copy Markdown

Closes #157.

Replaces the remaining direct fetch() calls with axios for consistency with the rest of the codebase.

  • services.jsx: OpenGIN calls use baseURL: "" so they keep hitting window.configs.apiUrl (/v1/...)
  • DocsPage.jsx: raw markdown fetch uses responseType: "text"
  • callers updated to consume returned data directly (no more .json())

Build passes (npm run build).


Note: AI assistance was used for this change.

Convert remaining direct fetch() calls to axios for consistency with
the rest of the codebase. OpenGIN service calls use baseURL: "" so they
keep targeting window.configs.apiUrl; raw markdown fetch uses
responseType: "text".
@prdai prdai force-pushed the feat/issue-157-fetch-to-axios branch from 284c539 to 90fa6cd Compare May 31, 2026 12:58

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the application's data fetching layer by migrating from native fetch to axios across several components and services, simplifying response handling by removing redundant .json() parsing. Feedback highlights two critical issues: a potential TypeError in PersonsTab.jsx if the relation-fetching API fails and returns undefined, and a copy-paste error in the fallback return value of fetchAllPersons in services.jsx that would cause crashes in its callers.

Comment thread src/pages/OrganizationPage/components/PersonsTab.jsx Outdated
Comment thread src/services/services.jsx
- PersonsTab: default fetchActiveRelationsForMinistry result to [] so a
  failed request does not throw on .forEach
- fetchAllPersons: return { body: [] } on error so callers reading
  .body do not crash (was an incorrect { dates, allMinistryData } shape)
@ChanukaUOJ

Copy link
Copy Markdown
Member

@prdai Thanks for the contribution. We will review the PR!

@ChanukaUOJ

ChanukaUOJ commented Jun 10, 2026

Copy link
Copy Markdown
Member

@prdai In the current application we use Tankstack to wrap all the axios calls. and access all the data through a hook. You can refer the XploreDataService.jsx for more information. We want to follow the same way here as well. Could you please do the same

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.

Change API calls that use fetch to axios calls

2 participants