ERROR [TypeError: Network request failed]

54 Views Asked by At

I am getting the ERROR:

[TypeError: Network request failed]

in my react native expo app js file for API Integration. The same API using in my react js web development it works well. But It didn't work in my react native expo mobile app.

2

There are 2 best solutions below

1
Surendhar S On

Don't use Local host address. Using public IPv4 address.

0
KTas On

Don't reference localhost from your app - instead during local development you can directly specify the IP address. Luckily you can get this at runtime using expo-constants.

import Constants from "expo-constants";

const { manifest } = Constants;

const uri = `http://${manifest.debuggerHost.split(':').shift()}:3000`;