React Native Fetch Http PUT Request Example
May 12, 2021 . Admin

In the first step Run the following command for create project.
expo init MywebtutsAppStep 2 - Install Package
In the step,I will install npm i react-native-paper package.
npm i react-native-paperStep 3 - App.js
In this step, You will open App.js file and put the code.
import React, { Component } from "react"; import { Text, View,StyleSheet,Button} from 'react-native'; import { Provider ,Appbar,Card,IconButton,Avatar,TextInput} from 'react-native-paper'; const MyWebtutsComponent = () => { const [isLoading, setLoading] = React.useState(true); const [firstName, setFirstNameText] = React.useState('Field'); const [lastName, setLastNameText] = React.useState('Mark'); const [email, setEmailText] = React.useState('fieldmark@gmail.com'); const requestOptions = { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ first_name:firstName,last_name:lastName,email:email }) }; const handleClick = async () => { fetch('https://api.mywebtuts.com/api/users/13', requestOptions) .then(response => response.json()) .then(data => console.log(data)); }; const _goBack = () => console.log('Went back'); const _handleSearch = () => console.log('Searching'); const _handleMore = () => console.log('Shown more'); return (Step 4 - Run project); }; const styles = StyleSheet.create({ title:{ margin: 10, fontSize: 15, fontSize: 35 }, mainbox:{ textAlign:'center', margin: 15, justifyContent: 'space-between', }, cardbox:{ margin: 10, }, labelText:{ marginTop: 10, marginBottom: 5, }, inputText:{ height:45, marginBottom: 15, }, buttonstyle:{ marginTop: 10, }, }); export default MyWebtutsComponent; Fist Name: setFirstNameText(firstName)} defaultValue={firstName} /> Last Name: setLastNameText(lastName)} defaultValue={lastName} /> Email: setEmailText(email)} defaultValue={email} />
In the last step run your project using bellow command.
npm startOutput

It will help you...