React Native - Call API on Button Click
import React from 'react';
import { View, Text, Button, TouchableOpacity,Alert }from 'react-native';
const App = () => {
const handleLogin = async() => {
let resp= await fetch('https://api.demo.com/api/Data/GetDestination');
let respjson = await resp.json();
console.log(respjson);
Alert.alert("msg", "123");
}
return(
<View>
<Text style={{fontSize:70}}>
Call Api
</Text>
<Button onPress={handleLogin}
title="Learn More"
color="#841584"
accessibilityLabel="Learn more about this purple button"
/>
<TouchableOpacity>
<Text onPress={handleLogin}>Login</Text>
</TouchableOpacity>
</View>
)
}
export default App