Commit Graph

15 Commits

Author SHA1 Message Date
grgmo d09cd62011 Add support for ontimeout and onerror handler when using XMLHttpRequest for Android and iOS
Summary: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).

With addition to two handlers, both Android and iOS can now handle `ontimeout` if request times out and `onerror` when there is general network error.

**Test plan**

Code 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.

**Usage**

JavaScript -

```
var request = new XMLHttpRequest();

function onLoad() {
    console.log(request.status);
};

function onTimeout() {
    console.log('Timeout');
};

function onError() {
    console.log('General network error');
};

request.onload = onLoad;
request.ontimeout = onTimeout;
request.onerr
Closes https://github.com/facebook/react-native/pull/6841

Differential Revision: D3178859

Pulled By: lexs

fb-gh-sync-id: 30674570653e92ab5f7e74bd925dd5640fc862b6
fbshipit-source-id: 30674570653e92ab5f7e74bd925dd5640fc862b6
2016-04-15 05:17:21 -07:00
Nick Baugh 72b274a9b9 Removed Parse reference since its service is shutting down
Summary:I updated the Network documentation to not lead users to use Parse, since its service is shutting down.
Closes https://github.com/facebook/react-native/pull/6140

Differential Revision: D2974665

fb-gh-sync-id: 2a784ad00f742f9f2e2ce369f8b3e1eaab0e2ad4
shipit-source-id: 2a784ad00f742f9f2e2ce369f8b3e1eaab0e2ad4
2016-03-07 16:46:04 -08:00
Alex Krolick 4b722d6d2a Add context to async example function in Network docs
Reviewed By: svcscm

Differential Revision: D2933584

fb-gh-sync-id: 24436b185791e3fa8047be521894545c08a90ee0
shipit-source-id: 24436b185791e3fa8047be521894545c08a90ee0
2016-02-12 13:39:31 -08:00
Hosain 70c89fa0d2 Update incorrect WebSocket example in Network.md
Using the provided WebSocket example under react-native 0.17, the sample code throws the following error:

"TypeError: ws.on is not a function(…)"

It's listening on ".on" which does not exist, rather than assigning a function to onopen, onmessage, onerror and onclose.

See: https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
2015-12-26 11:18:51 +00:00
Nick Baugh 7605d2d8cd Switched recommendation from superagent to frisbee, Moved XMLHTTPRequest to bottom of doc page
Resolves issues per recommendations by @ide

Added axios reference
2015-12-07 13:53:01 -05:00
Alex Krolick b5297fe5d4 extend Network/Fetch API documentation
- Mention that Fetch returns a Promise
  (makes example with .then clearer to newcomers to ES6/ES7)
- Add example of Fetch usage with second argument
  (helps clarify how e.g., a POST request to an API might be constructed)
- Add async/await example
2015-10-27 14:29:36 -07:00
Martin Konicek c819c5590b Add @satya164's WebSocket docs from #2839 2015-10-07 18:09:21 +01:00
David Rabkin 9b178b8f1a (docs) Update Network.md for clarification 2015-04-03 20:26:55 -07:00
Steve Lacy 6b7383072a Add possessive case to React 2015-03-26 15:39:53 -07:00
Steve Lacy a15c584f20 Adjust the plurality of goal to goals 2015-03-26 10:38:38 -07:00
Christopher Chedeau 616e29f723 Update Network.md 2015-03-22 09:33:24 -07:00
Christopher Chedeau 4f8a86e8d7 Website tweaks 2015-03-21 10:59:41 -07:00
Spencer Ahrens 9b95a896e9 Cleanup doc text. 2015-03-16 11:49:31 -07:00
Christopher Chedeau f598f05cc5 [Website] Put all the guides in the table of content 2015-03-13 21:30:00 -07:00
Christopher Chedeau 7fed64082c Create Network.md 2015-02-13 15:19:36 -08:00