-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fetch needs patched for try/catch on JSON.parse #4376
Comments
also why are you throwing errors instead of sending them back with Promise.reject? react-native/Libraries/Fetch/fetch.js Line 125 in 854689d
react-native/Libraries/Fetch/fetch.js Line 194 in 854689d
|
Basically because you are throwing errors and not wrapping JSON.parse in a try/catch block - I had to dig deep to find out that my 404 response could not use fetch(apiUri + path, {
method: 'GET',
headers: that.headers
})
.then((res) => res.json())
.then((res) => {
if (res && res.error)
return fn(res.error);
fn(null, res);
})
.catch(fn) The error is thrown that it can't parse JSON (the body is text response) |
The reason I have to use |
if an error is thrown inside the |
Hey niftylettuce, thanks for reporting this issue! React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.
|
Closing as per discussion in JakeChampion/fetch#235 |
Please fix
react-native/Libraries/Fetch/fetch.js
Line 232 in 854689d
The text was updated successfully, but these errors were encountered: