fetch and electron renderer fail
See original GitHub issueIn a electron renderer thread if you don’t bundle (nodeIntegration===true) you get whatever main prop a package points to, in this case we get the node version of ky.
But if we look at these lines https://github.com/sindresorhus/ky-universal/blob/master/index.js#L14-L16 we will get into troubles because the if clause tests if global.fetch
exists and in electron renderer that will be true because native web fetch is available.
So instead of using node-fetch we use native fetch, but when another package using ky
uses https://github.com/form-data/form-data with fetch it fails because form-data
only works with node-fetch.
To fix this either we detect the environment for this specific case and workaround it or we remove the if clauses since ky
already allows for lazy resolution of globals.
I’m happy to PR a fix, but would like some feedback on this first.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
This problem should be fixed by https://github.com/node-fetch/node-fetch/pull/603 in node-fetch v3 since it duck tests for FormData.
In the browser context, you can just import ky with
const ky = require("ky/umd")
.