Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace axios with a fetch based api reimplementation #63

Open
dominikg opened this issue Jul 1, 2024 · 14 comments
Open

replace axios with a fetch based api reimplementation #63

dominikg opened this issue Jul 1, 2024 · 14 comments
Labels
umbrella issue This issue contains a list of dependents of a package and tracks the progress in each

Comments

@dominikg
Copy link

dominikg commented Jul 1, 2024

redaxios https://github.com/developit/redaxios is pretty well known but not that active

developit/redaxios#97 mentions https://github.com/divyam234/feaxios which has recent activity also seems to implement more features.

Would save 2MB install size and 80% bundle size (10kb -> 2kb)

50M downloads/week with 140k dependents: https://www.npmjs.com/package/axios

@dominikg
Copy link
Author

dominikg commented Jul 1, 2024

This is a critical package/dependency too as it handles request/response, so could have access to all data of applications. Trust/track-record for the maintainer/org of the replacement package should be taken into account as well.

@43081j
Copy link
Collaborator

43081j commented Jul 1, 2024

i feel like most usages of axois could just use fetch

i'd be interested in the use cases where fetch isn't quite enough, if we can find some examples

also agreed we should take care to find a trusted, well maintained alternative

@dominikg
Copy link
Author

dominikg commented Jul 1, 2024

axios has a larger api and utilitity functions. a small drop-in replacement is a much easier sell than refactoring large codebases to remove all uses. I do agree that one should look at how axios is used and if it could be replaced by fetch directly without much effort.

@suhaotian
Copy link

What you think about this one https://github.com/suhaotian/xior

@dominikg
Copy link
Author

dominikg commented Jul 4, 2024

it doesn't seem to be 100% api compatible to axios: https://github.com/suhaotian/xior?tab=readme-ov-file#1-is-xior-100-compatiable-with-axios so it would not be usable as a drop-in replacement.

@suhaotian
Copy link

suhaotian commented Jul 4, 2024

Yeah, but the xior core features is drop-in replacement.

even the redaxios and feaxios is not 100% compatiable, and have ESM/commonjs issue.

And they don't support nested object in params, if want support then need to use qs package which is already gzip 10kb.

@dominikg
Copy link
Author

dominikg commented Jul 7, 2024

In that case it would help if you documented which parts of xior are api compatible to axios so people can recommend it over axios to projects that use only covered parts.

@suhaotian
Copy link

suhaotian commented Jul 8, 2024

  • Similar axios API: axios.create / axios.interceptors / .get/post/put/patch/delete/head/options

  • Additional: fetch parameters compatible, plugins support, better TS hints.

@fregante
Copy link

Replacing axios is easy, replacing all the tests based on axios is not. I was not able to find a drop-in replacement for axios-mock-adapter and all of the fetch-based mocks are different in substantial ways.

@talentlessguy
Copy link

there's https://github.com/sindresorhus/ky

@43081j
Copy link
Collaborator

43081j commented Jul 19, 2024

I think we should recommend that people use fetch instead of a third party package. That'll cover most use cases

Would be good to know some cases where fetch isn't enough

@talentlessguy
Copy link

I think we should recommend that people use fetch instead of a third party package. That'll cover most use cases

Would be good to know some cases where fetch isn't enough

tracking request progress

@Stanzilla
Copy link

i feel like most usages of axois could just use fetch

i'd be interested in the use cases where fetch isn't quite enough, if we can find some examples

also agreed we should take care to find a trusted, well maintained alternative

interceptors come to mind

@fry69
Copy link

fry69 commented Oct 5, 2024

For what it's worth: Here is transcript of prompting o1-mini requesting it to write a simple wrapper around fetch() with similar functionality like axios.

Maybe it is useful to gain some insight (it helped me) -> https://gist.github.com/fry69/6bdca157d02491809e577a4093273588

@Fuzzyma Fuzzyma added the umbrella issue This issue contains a list of dependents of a package and tracks the progress in each label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
umbrella issue This issue contains a list of dependents of a package and tracks the progress in each
Projects
None yet
Development

No branches or pull requests

8 participants