After adding a node module,isomorphic-fetch
(version : ^2.2.1) in React Native app, I am getting an error of Can't find variable: self
.
Here I have attached a screenshot.
The error is thrown from the file, located at node_modules > isomorphic-fetch > fetch-npm-browserify.js
.
Following is the code of that file.
// 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');
module.exports = self.fetch.bind(self);
@Nirav Dangi,按新建fetch-npm-react-native.js 的方式在我的项目里面没有起作用; 我这边处理方式,是直接修改,node_modules > isomorphic-fetch > fetch-npm-browserify.js 文件的返回:
Google Translate: @Nirav Dangi, in accordance with the new way fetch-npm-react-native.js in my project which is not working; I am here to deal with direct changes, node_modules> isomorphic-fetch> fetch-npm-browserify.js file Back:
var globalObject = typeof self === "undefined" ? global : self;
module.exports = globalObject.fetch.bind(globalObject);
//module.exports = fetch;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With