upvote
It doesn't matter. We pulled axios out of our codebase, but it still ends up in there as a child or peer from 40 other dependencies. Many from major vendors like datadog, slack, twilio, nx (in the gcs-cache extension), etc...
reply
People use axios or ky because with fetch you inevitably end up writing a small wrapper on top of it anyway.
reply
Fetch has also lacked support for features that xhr has had for over a decade now. For example upload progress. It's slowly catching up though, upload progress is the only thing I'd choose xhr for.
reply
You can pipe through a TransformStream that counts how many bytes you've uploaded, right?
reply
That is a way to approximate it, though I'd be curious to know the semantics compared to xhr - would they both show the same value at the same network lifecycle of a given byte?
reply
Some might say the tradeoff of writing a small wrapper is worth it given what’s been demonstrated here.
reply
Yeah but what about other deps like db drivers?
reply
In my experience people feel the need to wrap axios too.
reply
These are the kind of people I hope AI replaces
reply
AI was trained on Axios wrappers, so it's just going to be wrappers all the way down. Look inside any company "API Client" and it's just a branded wrapper around Axios.
reply
Speak for yourself, Claude works fine with fetch on my system.
reply
Node fetch is relatively new. Wasn't marked stable until 2023, though I've used it since like 2018.
reply
I'm not sure fetch is a good server-side API. The typical fetch-based code snippet `fetch(API_URL).then(r => r.json())` has no response body size limit and can potentially bring down a server due to memory exhaustion if the endpoint at API_URL malfunctions for some reason. Fine in the browser but to me it should be a no-no on the server.
reply
> I'm not sure fetch is a good server-side API. The typical fetch-based code snippet `fetch(API_URL).then(r => r.json())` has no response body size limit and can potentially bring down a server due to memory exhaustion if the endpoint at API_URL malfunctions for some reason. Fine in the browser but to me it should be a no-no on the server.

Nor is fetch a good client-side API either; you want progress indicators, on both upload and download. Fetch is a poor API all-round.

reply
Hm, I don't think axios would do much better here. `fetch` is the official replacement for axios. If both are flawed that's another topic
reply
Axios has maxContentLength and maxBodyLength options. I would probably go with undici nowadays though (it also has maxResponseSize).
reply
> `fetch` is the official replacement for axios.

No. Axios is still maintained. They have not deprecated the project in favor of fetch.

reply
I'm not saying that axios is unmaintained, I'm saying that if you want something like axios from the standard lib, fetch is the closest thing you get to official
reply
Sure but Axios determine what the official replacement for Axios is.
reply
It's not deprecated, it's obsoleted.
reply
deleted
reply
deleted
reply
It doesn't have a need _now_. Axios is more than 10 years old now, and even before axios other libraries did the same utility of making requests easier
reply
Browsers too.

It’s not needed anymore.

reply