import React from 'react';
import { FlatList, ActivityIndicator, Text, View } from 'react-native';
export default class DataFetcher extends React.Component {
constructor(props){
super(props);
this.state ={ isLoading: true}
}
componentDidMount(){
fetch('https://apitest.kuveytturk.com.tr/prep/v1/data/fecs', {
method: 'GET',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
firstParam: 'isoCode ',
secondParam: 'internationalCode',
thirdParam: 'name',
fourthParam: 'code',
FifthParam: 'group',
SixthParam: 'id'
}),
});
}
render(){
if(this.state.isLoading){
return(
<View style={{flex: 1, padding: 20}}>
<ActivityIndicator/>
</View>
)
}
return(
<View style={{flex: 1, paddingTop:20}}>
<FlatList
data={this.state.dataSource}
renderItem={({item}) => <Text>{item.isoCode}, {item.internationalCode}, {item.name}, {item.code}, {item.group}</Text>}
keyExtractor={({id}, index) => id}
/>
</View>
);
}
}
I am learning how to use React Native and I'm attempting to retrieve data from an API. However, I encountered an error with the code.
I received a possible unhandled promise rejection (ID 0) - TypeError: Undefined is not an object.
I am puzzled by why there is no object being returned.
I would greatly appreciate any assistance or guidance on this matter.