You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of Ky 1.0.0, it runs natively on Node.js. So this package is no longer needed.
Ky is made for browsers, but this package makes it possible to use it in Node.js too, by polyfilling most of the required browser APIs using node-fetch.
This package can be useful for:
Isomorphic code
Web apps (React, Vue.js, etc.) that use server-side rendering (SSR)
Testing browser libraries using a Node.js test runner
Note: Before opening an issue, make sure it's an issue with Ky and not its polyfills. Generally, if something works in the browser, but not in Node.js, it's an issue with node-fetch.
Keep in mind that Ky targets modern browsers when used in the browser. For older browsers, you will need to transpile and use a fetch polyfill.
Webpack will ensure the polyfills are only included and used when the app is rendered on the server-side.
How do I test a browser library that uses Ky in AVA?
Put the following in package.json:
{
"ava": {
"require": [
"ky-universal"
]
}
}
The library that uses Ky will now just work in AVA tests.
clone() hangs with a large response in Node - What should I do?
Streams in Node.js have a smaller internal buffer size (16 kB, aka highWaterMark) than browsers (>1 MB, not consistent across browsers). When using Ky, the default highWaterMark is set to 10 MB, so you shouldn't encounter many issues related to that.
However, you can specify a custom highWaterMark if needed: