-
Notifications
You must be signed in to change notification settings - Fork 0
/
CallApis.js
43 lines (41 loc) · 1015 Bytes
/
CallApis.js
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
33
34
35
36
37
38
39
40
41
42
43
/* eslint-disable prettier/prettier */
import {View, Text} from 'react-native';
import React from 'react';
import {getApiCall, postApiCall} from './ApiCalls';
import {allstyles} from './AllStyles';
const CallApis = () => {
const getData = () => {
getApiCall('https://jsonplaceholder.typicode.com/posts').then(res => {
console.log(res);
});
};
const postData = () => {
const data = {
title: 'test product',
price: 13.5,
description: 'lorem ipsum set',
image: 'https://i.pravatar.cc',
category: 'electronic',
};
postApiCall('https://fakestoreapi.com/products', data).then(res => {
console.log(res);
});
};
return (
<View
style={[
allstyles.container2,
{justifyContent: 'center', alignItems: 'center'},
]}>
<Text
style={{fontSize: 30}}
onPress={() => {
//getData();
postData();
}}>
CallApis
</Text>
</View>
);
};
export default CallApis;