mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Updated docs for next
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
<span class="token punctuation">}</span> <span class="token keyword">catch</span><span class="token punctuation">(</span>error<span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
||||
console<span class="token punctuation">.</span><span class="token function">error<span class="token punctuation">(</span></span>error<span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||||
<span class="token punctuation">}</span>
|
||||
<span class="token punctuation">}</span></div><p>Don't forget to catch any errors that may be thrown by <code>fetch</code>, otherwise they will be dropped silently.</p><h3><a class="anchor" name="using-other-networking-libraries"></a>Using Other Networking Libraries <a class="hash-link" href="docs/network.html#using-other-networking-libraries">#</a></h3><p>The <a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest" target="_blank">XMLHttpRequest API</a> is built in to React Native. This means that you can use third party libraries such as <a href="https://github.com/niftylettuce/frisbee" target="_blank">frisbee</a> or <a href="https://github.com/mzabriskie/axios" target="_blank">axios</a> that depend on it, or you can use the XMLHttpRequest API directly if you prefer.</p><div class="prism language-javascript"><span class="token keyword">var</span> request <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">XMLHttpRequest</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||||
<span class="token punctuation">}</span></div><p>Don't forget to catch any errors that may be thrown by <code>fetch</code>, otherwise they will be dropped silently.</p><blockquote><p>By default, iOS will block any request that's not encrypted using SSL. If you need to fetch from a cleartext URL (one that begins with <code>http</code>) you will first need to add an App Transport Security exception. If you know ahead of time what domains you will need access to, it is more secure to add exceptions just for those domains; if the domains are not known until runtime you can <a href="/react-native/docs/integration-with-existing-apps.html#app-transport-security" target="">disable ATS completely</a>. <a href="https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW33" target="_blank">See Apple's documentation for more information</a>.</p></blockquote><h3><a class="anchor" name="using-other-networking-libraries"></a>Using Other Networking Libraries <a class="hash-link" href="docs/network.html#using-other-networking-libraries">#</a></h3><p>The <a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest" target="_blank">XMLHttpRequest API</a> is built in to React Native. This means that you can use third party libraries such as <a href="https://github.com/niftylettuce/frisbee" target="_blank">frisbee</a> or <a href="https://github.com/mzabriskie/axios" target="_blank">axios</a> that depend on it, or you can use the XMLHttpRequest API directly if you prefer.</p><div class="prism language-javascript"><span class="token keyword">var</span> request <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">XMLHttpRequest</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||||
request<span class="token punctuation">.</span>onreadystatechange <span class="token operator">=</span> <span class="token punctuation">(</span>e<span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">></span> <span class="token punctuation">{</span>
|
||||
<span class="token keyword">if</span> <span class="token punctuation">(</span>request<span class="token punctuation">.</span>readyState <span class="token operator">!</span><span class="token operator">==</span> <span class="token number">4</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
||||
<span class="token keyword">return</span><span class="token punctuation">;</span>
|
||||
|
||||
Reference in New Issue
Block a user