mirror of
https://github.com/status-im/react-native.git
synced 2025-01-27 01:40:08 +00:00
Reject promise if network request failed
Summary:This adds missing check and promise reject for failing network requests. Which was missing in the fetch.js update. Sorry for the trouble. cc davidaurelio Closes https://github.com/facebook/react-native/pull/6368 Differential Revision: D3026830 Pulled By: davidaurelio fb-gh-sync-id: 028037678e148bb9b0a6a098d29ec7d82f64b607 shipit-source-id: 028037678e148bb9b0a6a098d29ec7d82f64b607
This commit is contained in:
parent
fa5783e3ee
commit
6470ff842b
@ -390,8 +390,14 @@ var self = {};
|
||||
}
|
||||
|
||||
xhr.onload = function() {
|
||||
var status = (xhr.status === 1223) ? 204 : xhr.status
|
||||
if (status < 100 || status > 599) {
|
||||
reject(new TypeError('Network request failed'))
|
||||
return
|
||||
}
|
||||
|
||||
var options = {
|
||||
status: xhr.status,
|
||||
status: status,
|
||||
statusText: xhr.statusText,
|
||||
headers: headers(xhr),
|
||||
url: responseURL()
|
||||
|
Loading…
x
Reference in New Issue
Block a user