apache / couchdb-nano

Nano: The official Apache CouchDB library for Node.js
https://www.npmjs.com/package/nano
Apache License 2.0
651 stars 165 forks source link

fetch instead of axios #307

Open konsumer opened 1 year ago

konsumer commented 1 year ago

If this library used fetch instead of axios (with cross-fetch as a polyfill for environments that don't have fetch) it would be usable in other js environments (deno, bun, cloudflare workers, maybe even browser!)

Possible Solution

Remove dependencies on axios, and use cross-fetch and standard fetch API.

I have seen browser-nano but haven't tested. It may already have support for this. This might be a nice way to merge these projects. It has a very thin wrapper to monkey-patch nano.

Context

For me specifically, it would enable me to use nano/couch more easily, directly with cloudflare workers (which have fetch built-in.)

glynnbird commented 1 year ago

Totally agree. Just need fetch to be in a node lts release.

On Tue, 25 Oct 2022, 20:46 David Konsumer, @.***> wrote:

If this library used fetch instead of axios (with cross-fetch as a polyfill for environments that don't have fetch) it would be usable in other js environments (deno, bun, cloudflare workers, maybe even browser!) Possible Solution

Remove dependencies on axios, and use cross-fetch and standard fetch API https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API.

I have seen browser-nano https://github.com/achesco/browser-nano but haven't tested. It may already have support for this. This might be a nice way to merge these projects. It has a very thin wrapper https://github.com/achesco/browser-nano/blob/master/lib/index.js to monkey-patch nano. Context

For me specifically, it would enable me to use nano/couch more easily, directly with cloudflare workers (which have fetch built-in.)

— Reply to this email directly, view it on GitHub https://github.com/apache/couchdb-nano/issues/307, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFKMRNJKYYTZNSRYQSUYDLWFA2IZANCNFSM6AAAAAAROJMI3E . You are receiving this because you are subscribed to this thread.Message ID: @.***>

SinanGabel commented 1 year ago

Great to move to fetch.

Just a note: I am still using nano version 8.2.3 as there are some cookie problems - in my setup - using nano versions 9.x and 10.x.

Thanks for all the work, it is greatly appreciated!