mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
update website
This commit is contained in:
+1
-1
@@ -12,7 +12,7 @@ request<span class="token punctuation">.</span>onreadystatechange <span class="t
|
||||
<span class="token punctuation">}</span><span class="token punctuation">;</span>
|
||||
|
||||
request<span class="token punctuation">.</span><span class="token function">open<span class="token punctuation">(</span></span><span class="token string">'GET'</span><span class="token punctuation">,</span> <span class="token string">'https://mywebsite.com/endpoint.php'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||||
request<span class="token punctuation">.</span><span class="token function">send<span class="token punctuation">(</span></span><span class="token punctuation">)</span><span class="token punctuation">;</span></div><p>Please follow the <a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest" target="_blank">MDN Documentation</a> for a complete description of the API.</p><p>As a developer, you're probably not going to use XMLHttpRequest directly as its API is very tedious to work with. But the fact that it is implemented and compatible with the browser API gives you the ability to use third-party libraries such as <a href="https://parse.com/docs/js_guide" target="_blank">Parse JS SDK</a> or <a href="https://github.com/visionmedia/superagent" target="_blank">super-agent</a> directly from npm.</p><h2><a class="anchor" name="fetch"></a>Fetch <a class="hash-link" href="#fetch">#</a></h2><p><a href="https://fetch.spec.whatwg.org/" target="_blank">fetch</a> is a better networking API being worked on by the standard committee and is already available in Chrome. It is available in React Native by default.</p><div class="prism language-javascript"><span class="token function">fetch<span class="token punctuation">(</span></span><span class="token string">'https://mywebsite.com/endpoint.php'</span><span class="token punctuation">)</span>
|
||||
request<span class="token punctuation">.</span><span class="token function">send<span class="token punctuation">(</span></span><span class="token punctuation">)</span><span class="token punctuation">;</span></div><p>Please follow the <a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest" target="_blank">MDN Documentation</a> for a complete description of the API.</p><p>As a developer, you're probably not going to use XMLHttpRequest directly as its API is very tedious to work with. But the fact that it is implemented and compatible with the browser API gives you the ability to use third-party libraries such as <a href="https://parse.com/products/javascript" target="_blank">Parse</a> or <a href="https://github.com/visionmedia/superagent" target="_blank">super-agent</a> directly from npm.</p><h2><a class="anchor" name="fetch"></a>Fetch <a class="hash-link" href="#fetch">#</a></h2><p><a href="https://fetch.spec.whatwg.org/" target="_blank">fetch</a> is a better networking API being worked on by the standard committee and is already available in Chrome. It is available in React Native by default.</p><div class="prism language-javascript"><span class="token function">fetch<span class="token punctuation">(</span></span><span class="token string">'https://mywebsite.com/endpoint.php'</span><span class="token punctuation">)</span>
|
||||
<span class="token punctuation">.</span><span class="token function">then<span class="token punctuation">(</span></span><span class="token punctuation">(</span>response<span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">></span> response<span class="token punctuation">.</span><span class="token function">text<span class="token punctuation">(</span></span><span class="token punctuation">)</span><span class="token punctuation">)</span>
|
||||
<span class="token punctuation">.</span><span class="token function">then<span class="token punctuation">(</span></span><span class="token punctuation">(</span>responseText<span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">></span> <span class="token punctuation">{</span>
|
||||
console<span class="token punctuation">.</span><span class="token function">log<span class="token punctuation">(</span></span>responseText<span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||||
|
||||
Reference in New Issue
Block a user