robinpowered / react-native-fetch-polyfill

Exposes options to React Native's XMLHttpRequest that are not accessible by `whatwg-fetch`
72 stars 23 forks source link

fetch does not work without `init` argument #8

Closed Li357 closed 6 years ago

Li357 commented 6 years ago

fetch doesn't work when you don't pass a second init argument, which is against the spec and what fetch normally does, i.e.

const response = await fetch('...');

Will fail with the error TypeError: init is undefined. This is due to trying to access the timeout property of init when it should check init exists before it does the access:

https://github.com/robinpowered/react-native-fetch-polyfill/blob/91bda0325bb7cdcb135b88b9e12f7699c2ec81df/fetch-polyfill.js#L43

atticoos commented 6 years ago

Published under v1.1.3, thanks for fixing this