Im testing react-native for the first time, and did a simple api call to a asp.net core web api:
import React, {Component} from 'react';
import axios from 'axios';
import {View, Text} from 'react-native';
import { FlatList } from 'react-native-gesture-handler';
class ApiCalls extends Component{
constructor(props){
super(props);
this.state = {
data: [
]
};
}
async getData(){
const response = await fetch('http://localhost:33255/api/Cities');
const json = await response.json();
this.setState({data: json})
} catch(error){
console.log(error);
}
componentDidMount(){
this.getData();
}
render(){
const {data} = this.state;
console.log(data);
return(
<View>
<FlatList
data={data}
keyExtractor={({ id }, index) => id}
renderItem={({ item }) =>(
<Text>{item.citiesId}, {item.cityName}, {item.zipCode}</Text>
)}
>
</FlatList>
</View>
)
}
}
export default ApiCalls;
So im able to get the data in the expo web browser:

But my expo app on my phone does not showing the data and i get the following error message:
"Possible unhandled Promise Rejection (id 0):"
"The operation couldn't be completed. Socket is not connected"
Any suggestions on how i can show the data in the expo app?