Skip to content

Fix "global is not defined" - #1704

Merged
jimmywarting merged 1 commit into
node-fetch:2.xfrom
segevfiner:patch-1
Jan 30, 2023
Merged

Fix "global is not defined"#1704
jimmywarting merged 1 commit into
node-fetch:2.xfrom
segevfiner:patch-1

Conversation

@segevfiner

Copy link
Copy Markdown

Purpose

I think this was missed in #1534

Changes

Replace global -> globalObject

Additional information

I get a global is not defined error otherwise. (octokit is still using this instead of isomorphic-fetch/cross-fetch)

@LinusU LinusU left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jimmywarting

jimmywarting commented Jan 19, 2023

Copy link
Copy Markdown
Collaborator

I think we should remove getGlobal and just use globalThis instead. and do we really need to use bind?

All in all:

"use strict";

const { fetch, Headers, Request, Response } = globalThis;

module.exports = exports = fetch;

// Needed for TypeScript and Webpack.
if (fetch) {
	exports.default = fetch;
}

exports.Headers = Headers;
exports.Request = Request;
exports.Response = Response;

@LinusU

LinusU commented Jan 30, 2023

Copy link
Copy Markdown
Member

@jimmywarting what do you think about releasing this PR as is, and then someone can open a new PR for further changes?

@jimmywarting

Copy link
Copy Markdown
Collaborator

sure

@jimmywarting
jimmywarting merged commit 70f592d into node-fetch:2.x Jan 30, 2023
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 2.6.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants