Comments (15)
My workaround right now is to use webpack's providerPlugin to load fetch for dev, deploy, but not test (separate webpack.config file for each env). That means of course that I cannot call actual fetch at all, but have to stub it via a mocking framework. This is all right for unit testing, but won't work for integration testing. Also disallows me from using sinon's fake server functionality (since that would require an actual fetch call).
from isomorphic-fetch.
@matthew-andrews seems to be uninterested in resolving this. As such, @lucasfeliciano created "fetch-everywhere" instead which is designed to work in every circumstance - https://github.com/lucasfeliciano/fetch-everywhere
from isomorphic-fetch.
@andrewmclagan Indeed :)
from isomorphic-fetch.
This issue also causes React Native to crash. The problem is if GitHub's library is loaded without a browser environment, self
isn't defined. I believe React Native's packager will include the script even if it is not required.
from isomorphic-fetch.
Having this same issue... Should we exclude something from the build (webpack externals
config) when building for Node to prevent this?
from isomorphic-fetch.
I got this fixed within GitHub's code (JakeChampion/fetch#253)
But my PR on this repo also needs to be merged to resolve this entirely: #63
from isomorphic-fetch.
Much obliged @billinghamj ! Just wait for the merge I guess
from isomorphic-fetch.
Yeah, I'm waiting for the merge as well. 👍
Since it is a quick fix I made the changes directly in the file on node_modules
just to keep developing.
from isomorphic-fetch.
What is the status of this merge?
from isomorphic-fetch.
@billinghamj Yes, just testing it :) Thanks :D
from isomorphic-fetch.
Same self is not defined
when trying to use command line mocha test and import fetch from 'isomorphic-fetch';
from isomorphic-fetch.
@matthew-andrews: Also experiencing this, is there no solid solution yet, or roadmap for this to be merged. The community seems to be drifting away from this lib in favour of fetch-everywhere simply due to this issue.
from isomorphic-fetch.
I'm still getting this issue
my solution: lucasfeliciano/fetch-everywhere#7
from isomorphic-fetch.
i had this error working with chai/mocha test.
fixed by this workaround:
add fix-global-self.js with:
global.self = global;
module.exports = global;
then import it at the top of my test:
import "./fix-global-self"
works for me.
from isomorphic-fetch.
Another solution is to make sure node has a self
property, via: https://www.npmjs.com/package/node-self.
from isomorphic-fetch.
Related Issues (20)
- Upgrade node-fetch to >= 2.3.0 to fix semantic-release users that use styled-components HOT 2
- Fix version of whatwg-fetch HOT 1
- eiddccgeilvtdejdrvblujinlecirnvcbbnnnunegklr
- AbortController not working with this library HOT 4
- URLSearchParams in body doesn't set content-type to x-www-form-urlencoded
- Is this library still been maintained? HOT 4
- Tag a new version with the security fix HOT 11
- Add v3.0.0 release notes HOT 2
- How to handle error messages from server - Question HOT 1
- Node.js - realFetch.call is not a function HOT 8
- Isomorphic-fetch Typescript setup HOT 2
- Upgrade node-fetch to version 2.6.1 or 3.0.0-beta.9 HOT 1
- fetch api
- update node-fetch to v3.x HOT 7
- Security risk
- Found a possible security concern HOT 2
- Interceptors
- How to access the referer using isomorphic fetch library? An example would help!
- Dual Form
- Isomorphic fetch returns response with empty stream body HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from isomorphic-fetch.