Before jumping into React Native: Networking, you must have an understanding of React Native: ListView.
Numerous mobile applications need to load data from a remote URL. You might need to make a POST request to a REST API, or you may need to fetch some information from another server.
React Native gives the Fetch API to your networking needs. Fetch will appear to be recognizable if you have utilized XMLHttpRequest or other networking APIs previously.
So, to fetch content from a random URL, you can pass the URL to fetch:
Handling the response
Networking is a naturally asynchronous operation. Fetch strategies will return a Promise that makes it direct to compose code that works asynchronously:
Fetch also takes a discretionary second argument that enables you to customize the HTTP request. You might want to specify extra headers or make a POST request.
Using Other Networking Libraries
The XMLHttpRequest API is incorporated with React Native. This implies you can utilize third-party libraries that rely upon it, or you can utilize the XMLHttpRequest API directly if you like.
Respond Native additionally supports WebSockets, a protocol that gives full-duplex communication channels over a single TCP connection.