openfga/js-sdk

Replace axios

rhamzeh opened this issue · 5 comments

Summary

axios v1 has brought a few breaking changes, so now's the time to reconsider whether it still is the best solution we have.

Motivation(s)

  • http2/http3 support
  • streaming support
  • reduce dependencies

Downsides

  • Breaking change - axios is very tied to our responses, anyone who currently depends on them will have some work to do before they can upgrade

Alternatives to consider

  • axios: it's working, stick to it, but update to a v1.x.x+ version (no http2 support yet)
  • fetch: built into recent browsers and node 18+
  • gaxios: close to the axios interface, supports http2, no browser support
  • got: Seems to satisfy a lot constraints. No browser support and has a lot of dependencies
  • ky: tiny, no dependencies, supports deno
  • undici: from the core node devs
  • ...

Criteria for success

  • Compatible license (required)
  • Node.js 18+ support (required)
  • Brings in a minimal set of dependencies (required)
  • Promise based (required)
  • Preferably not another dependency
  • Streaming support: allows us to expose the streaming ListObjects
  • http2/http3 support: reduces request overhead
  • Browser support: needed for the Playground
  • Deno support (#17)
  • Error handling and automated retries (bonus - lets us drop our own implementation)
  • Credential flow support (bonus - lets us drop our own implementation)
  • Built-in caching support (bonus)

I can definitely recommend ky. It's fetch with an excellent interface.