Closed dalanmiller closed 8 years ago
this happens because whatwg-fetch didn't add .fetch
to "globalObj" in your case.
it occurs if globalObj is not the chosen target for whatwg-fetch.
When using webpack, you'll have to import/export isomorphic-fetch as follows:
global.self = global
require('imports?this=>global!exports?global.fetch!isomorphic-fetch')
Hey @dalanmiller, thank you for the issue.
I'll investigate it and comeback with a PR or something else to add to the discussion.
Can you tell me your env versions?
I just realised that the read me was wrong.
you should npm install fetch-everywhere
This error that you getting is basically the motivation for the fork.
Can you try install the right module and see if it works?
I installed fetch-everywhere
per the updated README but I still receive the same error message.
I had the same problem. It seems as though this
is not referring to the global object in fetch-npm-browserify, but you can get at it with self
// the whatwg-fetch polyfill installs the fetch() function
// on the global object (window or self)
//
// Return that as the export for use in Webpack, Browserify etc.
require('whatwg-fetch');
var globalObj = self || this.self || this;
module.exports = globalObj.fetch.bind(globalObj);
True that, sorry for the one month delay on this issue.
Startup life was consuming me.
@willmcclellan is right. Making the fix now.
Hi,
I see this issue is closed, but I am still receiving this error when using it with webpack. Is there a workaround I can use to to fix the issue? It seems like my code isn't using "self", "this.self" or "this" for some reason. When I tried using:
global.self = global require('imports?this=>global!exports?global.fetch!isomorphic-fetch')
I got an error saying "Cannot resolve module 'imports'" when I tried to build it via webpack.
Thanks!
I'm experiencing this in a React Native environment. Please let me know if I can help you with anything to solve this issue.
In my case, it seems the module is interfering with React Native's InteractionManager
promise. I get the Cannot read property 'bind' of undefined
.
Why would this be happening?
fetch
doesn't seem to be available.