Axios not receiving any response from Android Emulator

Viewed 70

When I run my React Native project on my physical device all requests are working fine, and I'm receiving responses for each request. But when I run the project on my emulator I can just see the payload,

enter image description here

I'm receiving nothing. What will be the cause for such a thing? Why this works on my physical device and not in my emulator? Below is my axios request body,

import axios from 'axios';

export const http = axios.create({
  baseURL: 'https://02de-113-59-214-59.ap.ngrok.io/api',
  headers: {
    'Content-type': 'application/json',
    Accept: 'application/json',
  },
});

Update: Actually the response received after a very long time what will be the cause for this?

Really appreciate it if somebody could help me thanks. Have a nice day

1 Answers

Check android emulator is connected to internet on laptop,if not connect try this:

Windows & Linux:

https://developers.google.com/speed/public-dns/docs/using

MacOSX:

Open System Preferences>Network

Select the network which your computer is connected and click on "Advanced" Select "DNS", Select the "+" button, type "8.8.8.8" (Google's DNS) or if you prefer OpenDNS, "208.67.222.222" Select "Ok" and "Apply"

Related