O'Reilly logo

React Native Cookbook by Crysfel Villa, Stan Bershadskiy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required