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

245
Visualizações
How to fetch data from dot net core in React Native?

Postman Screenshot of dot net core API

Postman fetches the data from my dot net core API but I cannot get the data in React native using the same API. I tried everything like changing port number etc.

React Native API Request

useEffect(() => {
    const getData= async () => {
     try {
        const response = await axios.get('http://10.0.2.2:54669/DoctorMaster/Getalldoctorssearch/1062');
        setAppointments(response.data);
        setIsLoading(false);
        console.log(response.data);
       
        
       
     } catch (error) {
       console.log(error);     
       
     }
    }
    getData()
  }, [setAppointments, setIsLoading]);
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

Please follow the below structure

fetch(
  "url"
  {
    method: "GET",
    headers: {
      Accept: "application/json",
      "Content-Type": "application/json",
      Authorization: "Bearer " + JSON.parse(token),
    },
  }
)
  .then((response) => response.json())
  .then((responseJson) => {
    // Handle response here
  })
  .catch((error) => {
    console.error(error);
  });
about 4 years ago · Juan Pablo Isaza Relatório

0

Be aware that React Native refuses HTTP requests instead of HTTPS requests by default:

To handle HTTP requests in Android see this post

To handle HTTP requests in iOS see this post

about 4 years ago · Juan Pablo Isaza Relatório

0

You are trying to fetch data from localhost which your mobile device won´t be able to fetch the url. You need to publish your API on a Web Server, and then you will be able to fetch the data

about 4 years ago · Juan Pablo Isaza Relatório
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