Am new to react native, am trying to access remote url throws this error. "undefined is not a function evaluating ((0,_reactNative.fetch)". Not sure what am doing wrong; Please help. Am using the latest version of react native 0.40
import React, { Component } from "react";
import {
View,
Text,
Button,
fetch,
NativeModules,
NativeEventEmitter
} from "react-native";
export default class VideoScreen extends Component {
componentDidMount(){
this.video();
}
video(){
fetch('http://localhost:4200/token').then(function(res) {
console.log(res.json());
})
}
}
removing fetch from the import statement makes it work.
import {
View,
Text,
Button,
NativeModules,
NativeEventEmitter
} from "react-native";
I had the same problem and it is resolved by adding this code to App.js :
if(typeof global.self === "undefined")
{
global.self = global;
}