typesense-js icon indicating copy to clipboard operation
typesense-js copied to clipboard

feat: Switch from axios to fetch

Open viktorlarsson opened this issue 6 months ago • 4 comments

Change Summary

Since Cloudflare workers and Vercel Edge runtimes does not support Axios, the intent here is to switch to native fetch (which has been supported since Node v18.0.0). This should probably be a major bump, but trying not to break contracts as much as possible.

Fixes #161

Investigations needed

  • [ ] check crypto, http and https support on edge enviromnets
  • [ ] creating a pluggable http client, so we could in theory pass axios, or fetch
  • [ ] keep alive wont work in edge, maybe add a typeguard for this?
  • [ ] make tests pass
  • [ ] multiple runtimes during tests? e.g node edge etc

Changes

  • I needed to write a wrapper on fetch, called FetchWithTimeout to support connectionTimeout. Added a new folder called Shared, not sure that is correct but it is not tied to Typesense in that manner.

PR Checklist

viktorlarsson avatar Aug 23 '24 11:08 viktorlarsson