react-notion-x icon indicating copy to clipboard operation
react-notion-x copied to clipboard

Switch from got to ky + fetch in notion-client

Open transitive-bullshit opened this issue 3 years ago • 4 comments
trafficstars

This PR removes got in favor of ky in notion-client. This means that notion-client is no longer tied to Node.js.

ky is a thin wrapper around fetch, which makes notion-client compatible with edge runtimes such as Cloudflare Workers, Vercel edge functions, and Deno.

It also adds a secondary entrypoint to notion-client which will only be used by "browsers" (and this should include edge runtimes, though this hasn't been tested yet in practice).

The node.js entrypoint bundles ky-universal, which polyfills node-fetch and abort-controller for node.js so that ky works in node.js the same as any other fetch-supported environment.

The main advantage of using ky instead of fetch directly is that ky includes robustness features such as automatic HTTP status code-aware retrying.

The main downside of this change is that got is more robust on node.js than any other fetch-based HTTP client that I'm aware of, including ky (though ky is the best fetch-based HTTP client that I'm aware of).

See @remorses previous PR which started this work in #312 and related discussion in #160

cc @pbteja1998 @MartinXPN @on2air

transitive-bullshit avatar Oct 17 '22 22:10 transitive-bullshit

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
react-notion-x ✅ Ready (Inspect) Visit Preview Oct 17, 2022 at 10:28PM (UTC)
react-notion-x-minimal-demo ✅ Ready (Inspect) Visit Preview Oct 17, 2022 at 10:28PM (UTC)

vercel[bot] avatar Oct 17 '22 22:10 vercel[bot]

This is awesome. Thanks for this. I will be happy to test it out on Cloudflare Workers once it's live.

pbteja1998 avatar Oct 17 '22 23:10 pbteja1998

Hi, I wanted to know if there was any reason this PR isn't merge yet?

nijamaDev avatar Dec 18 '22 17:12 nijamaDev

is there any reasons that PR isn't merge?

lhojun avatar Nov 08 '23 00:11 lhojun