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.
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.
Let's open the
index.ios.js
andindex.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);
Now we need to create the
src/MainApp.js
file, import the dependencies, and define three properties on thestate
:import React, { PureComponent } from 'react'; import { Alert, ScrollView, StyleSheet...