{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react-native/issues/6841","repository_url":"https://api.github.com/repos/facebook/react-native","labels_url":"https://api.github.com/repos/facebook/react-native/issues/6841/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/6841/comments","events_url":"https://api.github.com/repos/facebook/react-native/issues/6841/events","html_url":"https://github.com/facebook/react-native/pull/6841","id":146362100,"number":6841,"title":"[XMLHttpRequest] Add support for ontimeout and onerror handler when using XMLHttpRequest for Android and iOS","user":{"login":"grgmo","id":6507800,"avatar_url":"https://avatars.githubusercontent.com/u/6507800?v=3","gravatar_id":"","url":"https://api.github.com/users/grgmo","html_url":"https://github.com/grgmo","followers_url":"https://api.github.com/users/grgmo/followers","following_url":"https://api.github.com/users/grgmo/following{/other_user}","gists_url":"https://api.github.com/users/grgmo/gists{/gist_id}","starred_url":"https://api.github.com/users/grgmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grgmo/subscriptions","organizations_url":"https://api.github.com/users/grgmo/orgs","repos_url":"https://api.github.com/users/grgmo/repos","events_url":"https://api.github.com/users/grgmo/events{/privacy}","received_events_url":"https://api.github.com/users/grgmo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/react-native/labels/CLA%20Signed","name":"CLA Signed","color":"e7e7e7"},{"url":"https://api.github.com/repos/facebook/react-native/labels/GH%20Review:%20review-needed","name":"GH Review: review-needed","color":"fbca04"}],"state":"open","locked":false,"assignee":{"login":"lexs","id":191973,"avatar_url":"https://avatars.githubusercontent.com/u/191973?v=3","gravatar_id":"","url":"https://api.github.com/users/lexs","html_url":"https://github.com/lexs","followers_url":"https://api.github.com/users/lexs/followers","following_url":"https://api.github.com/users/lexs/following{/other_user}","gists_url":"https://api.github.com/users/lexs/gists{/gist_id}","starred_url":"https://api.github.com/users/lexs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lexs/subscriptions","organizations_url":"https://api.github.com/users/lexs/orgs","repos_url":"https://api.github.com/users/lexs/repos","events_url":"https://api.github.com/users/lexs/events{/privacy}","received_events_url":"https://api.github.com/users/lexs/received_events","type":"User","site_admin":false},"milestone":null,"comments":10,"created_at":"2016-04-06T16:12:55Z","updated_at":"2016-04-10T14:56:44Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/facebook/react-native/pulls/6841","html_url":"https://github.com/facebook/react-native/pull/6841","diff_url":"https://github.com/facebook/react-native/pull/6841.diff","patch_url":"https://github.com/facebook/react-native/pull/6841.patch"},"body":"Currently React-Native does not have `ontimeout` and `onerror` handlers for [XMLHttpRequest](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest). This is an extension to [No timeout on XMLHttpRequest](https://github.com/facebook/react-native/issues/4648).\r\n\r\nWith addition to two handlers, both Android and iOS can now handle `ontimeout` if request times out and `onerror` when there is general network error.\r\n\r\n**Test plan**\r\n\r\nCode has been tested on both Android and iOS with [Charles](https://www.charlesproxy.com/) by setting a breakpoint on the request which fires `ontimeout` when the request waits beyond `timeout` time and `onerror` when there is network error.\r\n\r\n**Usage**\r\n\r\nJavaScript - \r\n\r\n```\r\nvar request = new XMLHttpRequest();\r\n\r\nfunction onLoad() {\r\n    console.log(request.status);\r\n};\r\n\r\nfunction onTimeout() {\r\n    console.log('Timeout');\r\n};\r\n\r\nfunction onError() {\r\n    console.log('General network error');\r\n};\r\n\r\nrequest.onload = onLoad;\r\nrequest.ontimeout = onTimeout;\r\nrequest.onerror = onError;\r\nrequest.open('GET', 'https://mywebsite.com/endpoint.php');\r\nrequest.send();\r\n```"},"comment":{"url":"https://api.github.com/repos/facebook/react-native/issues/comments/207996281","html_url":"https://github.com/facebook/react-native/pull/6841#issuecomment-207996281","issue_url":"https://api.github.com/repos/facebook/react-native/issues/6841","id":207996281,"user":{"login":"facebook-github-bot","id":6422482,"avatar_url":"https://avatars.githubusercontent.com/u/6422482?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook-github-bot","html_url":"https://github.com/facebook-github-bot","followers_url":"https://api.github.com/users/facebook-github-bot/followers","following_url":"https://api.github.com/users/facebook-github-bot/following{/other_user}","gists_url":"https://api.github.com/users/facebook-github-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook-github-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook-github-bot/subscriptions","organizations_url":"https://api.github.com/users/facebook-github-bot/orgs","repos_url":"https://api.github.com/users/facebook-github-bot/repos","events_url":"https://api.github.com/users/facebook-github-bot/events{/privacy}","received_events_url":"https://api.github.com/users/facebook-github-bot/received_events","type":"User","site_admin":false},"created_at":"2016-04-10T14:56:44Z","updated_at":"2016-04-10T14:56:44Z","body":"@grgmo updated the pull request."}}