lquixada / cross-fetch

Universal WHATWG Fetch API for Node, Browsers and React Native.
MIT License
1.66k stars 102 forks source link

Upgrade to node-fetch 3.x using `node-fetch-cjs`? #146

Open valerieernst opened 1 year ago

valerieernst commented 1 year ago

We're running into issues that are solved by https://github.com/node-fetch/node-fetch/pull/671, which is part of the node-fetch 3.0.0 release.

I read through https://github.com/lquixada/cross-fetch/issues/118 and understand upgrading node-fetch to v3.x+ isn't on the short term roadmap.

Is there any consideration to upgrading using https://github.com/touchifyapp/node-fetch-cjs? Seems like it could be an easier upgrade path.

If it's something you're considering, I'm happy to help out/put up a PR!

jimmywarting commented 1 year ago

fyi. it's also considerable easy to load node-fetch@3 from cjs using something like async import that works from cjs as well.

const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));

the disadvantage would be that you can't have sync access to Request/Response/Headers etc. also, node-fetch is kind of being replaced with the built in fetch from NodeJS v18. so packages like this will not be needed anymore. Just need to update to a newer NodeJS version.