skip to Main Content

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

Answers


  1. Chosen as BEST ANSWER

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


  2. 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`;
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search