fetch-mock icon indicating copy to clipboard operation
fetch-mock copied to clipboard

fix: do not require `node-fetch` for Node 18+

Open gr2m opened this issue 2 years ago • 6 comments

Node 18 comes with a built-in fetch function now. This simple change makes it compatible to use with Node 18, without requiring the install of node-fetch

gr2m avatar Sep 23 '22 23:09 gr2m

If anyone would like to use this fork: you can temporarily set an alias in your package.json dependencies

  "fetch-mock": "npm:@gr2m/[email protected]"

I'm using it in https://github.com/octokit/octokit-next.js for the time being

gr2m avatar Sep 23 '22 23:09 gr2m

@wheresrhys could you please merge this one? Thanks!

And regarding the patch above ^^ the correct version is

"fetch-mock": "npm:@gr2m/[email protected]",

Kamahl19 avatar Jan 24 '23 17:01 Kamahl19

And regarding the patch above ^^ the correct version is

"fetch-mock": "npm:@gr2m/[email protected]",

Fixed my comment, thanks!

gr2m avatar Jan 25 '23 00:01 gr2m

Can this be merged asap?

mfernandes-alcumus avatar Aug 22 '23 12:08 mfernandes-alcumus

The last commit in the default branch is from Sep 23, 2021, don't expect it to be merged any time soon. I'd recommend to use my fork for the time being.

This is an independent open source project, we are not entitled to anything, we can just offer to help. I'd recommend to avoid things like "asap", I'm sure you mean well, but nobody is paid to work on this project. Best to ask kindly, or not at all, in this case.

gr2m avatar Aug 22 '23 16:08 gr2m

In case anyone else stumbles across this, you can patch Node’s global fetch with fetch-mock via:

import fetchMock from 'fetch-mock'
globalThis.fetch = fetchMock.sandbox()

GeoffreyBooth avatar Aug 30 '23 21:08 GeoffreyBooth

fetch-mock 10 is now out with support for native fetch. Apologies for the delay

wheresrhys avatar Jun 15 '24 18:06 wheresrhys

Wonderful, thank you!!

gr2m avatar Jun 15 '24 21:06 gr2m