Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

108
Views
Expo React-Native app do not showing data from ApiCall

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: enter image description here

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?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!