Sending data to a Remote API

In the previous recipe, we learned how to get data from an API using fetch. In this recipe, we will learn how to POST data to the same endpoint to add new bookmarks.

Getting ready

Before going through this recipe, we need to create an empty app named SendingData. You can use any other name; just make sure you set the correct name when registering the app.

How to do it...

  1. Let's open the index.ios.js and index.android.js files, remove the previous code, and add the following:
            import React from 'react'; 
            import { AppRegistry } from 'react-native'; 
            import MainApp from './src/MainApp'; 
     
            AppRegistry.registerComponent('SendingData', () => MainApp); 
    
  2. Now we need to create the src/MainApp.js file, import ...

Get React Native Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.