Closed msluther closed 5 years ago
Seems like this old PR was also seeing the global fetch
getting stomped as well. This feels like a better fix though and more understandable.
Your work is great but there's something missing: a dummy react-native polyfill. The reason why this is important is that, given the same js file, it is supposed to work regardless of the environment. Thus, this snippet:
import 'cross-fetch/polyfill'
fetch('https://api.github.com/users/lquixada')
.then(res => {
if (res.status >= 400) {
throw new Error('Bad response from server')
}
return res.json()
})
.then(user => {
console.log(user)
})
.catch(err => {
console.error(err)
})
would work in the node and in the browser environments but it would break in react-native. So my suggestion is to create a react-native polyfill that does nothing. :)
Good call on the polyfill. Will do that as well.
Thanks! Awesome work!
This is an attempt to fix this issue such that:
fetch
global.fetch
isn't set tofalse