Skip to content

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

Closed
gr2m wants to merge 2 commits intowheresrhys:mainfrom
gr2m:patch-1
Closed

fix: do not require node-fetch for Node 18+#644
gr2m wants to merge 2 commits intowheresrhys:mainfrom
gr2m:patch-1

Conversation

@gr2m
Copy link
Copy Markdown

@gr2m gr2m commented Sep 23, 2022

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

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
Copy link
Copy Markdown
Author

gr2m commented Sep 23, 2022

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

  "fetch-mock": "npm:@gr2m/fetch-mock@9.11.0-pull-request-644.1"

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

@Kamahl19
Copy link
Copy Markdown

Kamahl19 commented Jan 24, 2023

@wheresrhys could you please merge this one? Thanks!

And regarding the patch above ^^ the correct version is

"fetch-mock": "npm:@gr2m/fetch-mock@9.11.0-pull-request-644.1",

@gr2m
Copy link
Copy Markdown
Author

gr2m commented Jan 25, 2023

And regarding the patch above ^^ the correct version is

"fetch-mock": "npm:@gr2m/fetch-mock@9.11.0-pull-request-644.1",

Fixed my comment, thanks!

@mfernandes-alcumus
Copy link
Copy Markdown

Can this be merged asap?

@gr2m
Copy link
Copy Markdown
Author

gr2m commented Aug 22, 2023

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.

@GeoffreyBooth
Copy link
Copy Markdown

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()

@wheresrhys
Copy link
Copy Markdown
Owner

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

@wheresrhys wheresrhys closed this Jun 15, 2024
@gr2m
Copy link
Copy Markdown
Author

gr2m commented Jun 15, 2024

Wonderful, thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants