refactor: replace fetch API with axios (#157)#159
Conversation
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".
284c539 to
90fa6cd
Compare
There was a problem hiding this comment.
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.
- 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)
|
@prdai Thanks for the contribution. We will review the PR! |
|
@prdai In the current application we use |
Closes #157.
Replaces the remaining direct
fetch()calls withaxiosfor consistency with the rest of the codebase.services.jsx: OpenGIN calls usebaseURL: ""so they keep hittingwindow.configs.apiUrl(/v1/...)DocsPage.jsx: raw markdown fetch usesresponseType: "text".json())Build passes (
npm run build).Note: AI assistance was used for this change.