-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp_Axios.js
More file actions
32 lines (28 loc) · 810 Bytes
/
App_Axios.js
File metadata and controls
32 lines (28 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { View, Text } from 'react-native'
import React from 'react'
import axios from 'axios'
import { TouchableOpacity } from 'react-native-gesture-handler';
const App = () => {
const getDataUsingaxios = async ()=>{
try {
const response = await axios.get('https://jsonplaceholder.typicode.com/posts/1');
alert(JSON.stringify(response.data));
} catch (error) {
alert(error.messgae);
}
};
return (
<View style = {StyleSheet.container}>
<Text style = {{ fontSize: 20, textAlign: 'center' }}>
Example of axios in React Native
</Text>
<TouchableOpacity
style = {StyleSheet.buttonStyle}
onPress = {getDataUsingaxios}
>
<Text>Get Data Using axios get</Text>
</TouchableOpacity>
</View>
)
}
export default App