Fix https://github.com/github/fetch/issues/657#794
Merged
JakeChampion merged 3 commits intomasterfrom Jul 9, 2020
Merged
Conversation
jungdj
reviewed
Jul 10, 2020
| var global = (function(self) { | ||
| return self | ||
| // eslint-disable-next-line no-invalid-this | ||
| })(typeof self !== 'undefined' ? self : this) |
There was a problem hiding this comment.
Can you please add some fallback such as an empty object?
I know this whatwg-fetch is intended to be used only in browser, however, it gives many conveniences by just "importing it" and not using it.
There was a problem hiding this comment.
To illustrate more, I'm suggesting to make importing 'whatwg-fetch' in nodejs environment works, while blocking the usage.
Owner
Author
There was a problem hiding this comment.
This works in NodeJS correctly because the global this works in NodeJS.
Here the output of running it in NodeJS
❯ node -v
v14.4.0
❯ node
Welcome to Node.js v14.4.0.
Type ".help" for more information.
> var global = (function(self) {
... return self
... // eslint-disable-next-line no-invalid-this
... })(typeof self !== 'undefined' ? self : this)
undefined
> global
<ref *1> Object [global] {
global: [Circular *1],
clearInterval: [Function: clearInterval],
clearTimeout: [Function: clearTimeout],
setInterval: [Function: setInterval],
setTimeout: [Function: setTimeout] {
[Symbol(nodejs.util.promisify.custom)]: [Function (anonymous)]
},
queueMicrotask: [Function: queueMicrotask],
clearImmediate: [Function: clearImmediate],
setImmediate: [Function: setImmediate] {
[Symbol(nodejs.util.promisify.custom)]: [Function (anonymous)]
}
}
>
(To exit, press ^C again or ^D or type .exit)
>
This was referenced Jun 6, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #657