← Back to context

Comment by pier25

24 days ago

People use axios or ky because with fetch you inevitably end up writing a small wrapper on top of it anyway.

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.

  • You can pipe through a TransformStream that counts how many bytes you've uploaded, right?

    • That would show how quickly the data is passing into the native fetch call but doesn’t account for kind of internal buffer it might have, network latency etc

    • 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?

In my experience people feel the need to wrap axios too.

  • These are the kind of people I hope AI replaces

    • I have never consciously wrapped Axios or fetch, but a cursory search suggests that there was a time when it was impossible for either to force TLS1.3. It's easy to imagine alternate implementations exist for frivolous reasons, but sometimes there are hard security or performance requirements that force you into them.

    • 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.

      1 reply →