0

When I use fetch() method to make get request, it failed with "TypeError: Network request failed". It's weird that it sometimes failed but sometimes succeeded. I have tried the solution here: React Native fetch() Network Request Failed, but it didn't work for me. By the way, I am using Android.

This is my code :

try {
  let url = "http://140.116.245.229:3000/GetCarsJson";

  let data = await fetch(url);
  let toJson = await data.json();
} catch(err) {
  throw err;
}

This is the error message : enter image description here

1 Answers1

0

You should ensure your devices/simulator/emulator can connect to this endpoint

If you use Android emulator, you can refer this link How to connect to a local server from an android emulator?

Dinh Huynh
  • 204
  • 1
  • 5