Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

107
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda