Skip to content

Migrate from axios to native Fetch#287

Merged
cigamit merged 7 commits intomainfrom
adios-axios
Apr 1, 2026
Merged

Migrate from axios to native Fetch#287
cigamit merged 7 commits intomainfrom
adios-axios

Conversation

@cigamit
Copy link
Copy Markdown
Contributor

@cigamit cigamit commented Apr 1, 2026

In light of the recent axios compromise (which didn't affect us, we are on an older version); I thought it best to re-examine our use of it.

There are other alternatives now, including the browser native function Fetch, which can be used without any dependencies. We only use axios in a single location in Base.js, which makes replacing it fairly trivial.

This PR takes care of replacing axios with the native fetch. The only drawback is we must now handle building the requests, catching errors, etc.. ourselves, but as you can see, its not that much more code to do so.

This ends up removing a total of 6 npm packages (dependencies of dependencies) and moves another 16 to be only dev dependencies.

@cigamit cigamit requested a review from TheWitness April 1, 2026 04:42
@cigamit cigamit self-assigned this Apr 1, 2026
Copilot AI review requested due to automatic review settings April 1, 2026 04:42
@cigamit cigamit added enhancement New feature or request dependencies Pull requests that update a dependency file javascript Pull requests that update javascript code labels Apr 1, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes axios from the AWX UI and replaces the shared API HTTP client in awx/ui/src/api/Base.js with a native fetch-based implementation, reducing transitive npm dependencies while keeping the existing API wrapper surface (get/post/put/patch/delete/options) intact.

Changes:

  • Replace axios.create(...) + response interceptor logic with a custom fetch wrapper (makeRequest/handleResponse) in Base.js.
  • Update Jest test setup to mock global.fetch instead of mocking axios.
  • Remove axios from awx/ui/package.json and update documentation describing query param serialization.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
awx/ui/src/setupTests.js Switch network-request guard from axios mocking to global.fetch mocking.
awx/ui/src/api/Base.js Implement a fetch-based HTTP client replacing axios (CSRF header, params, response parsing, error shaping, session timeout header handling).
awx/ui/SEARCH.md Update REST API search docs to remove axios-specific language.
awx/ui/package.json Drop axios dependency.
awx/ui/package-lock.json Remove axios and adjust transitive dependency graph/dev flags accordingly.
Files not reviewed (1)
  • awx/ui/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread awx/ui/src/setupTests.js Outdated
Comment thread awx/ui/src/api/Base.js
Comment thread awx/ui/src/api/Base.js
Comment thread awx/ui/src/api/Base.js
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • awx/ui/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread awx/ui/src/api/Base.js
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • awx/ui/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread awx/ui/src/api/Base.js
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • awx/ui/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread awx/ui/src/setupTests.js Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • awx/ui/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread awx/ui/src/api/Base.js Outdated
Comment thread awx/ui/src/api/Base.js Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • awx/ui/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread awx/ui/src/setupTests.js Outdated
@cigamit cigamit merged commit 120171d into main Apr 1, 2026
@cigamit cigamit deleted the adios-axios branch April 1, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file enhancement New feature or request javascript Pull requests that update javascript code

Development

Successfully merging this pull request may close these issues.

3 participants