Why your React Native app can't connect to your local .NET API (And how to fix it)
You just built a beautiful .NET Core Web API. You test it in Swagger or Postman, and it works perfectly. It returns data instantly. So, you open up your React Native Expo app, write a simple axios....

Source: DEV Community
You just built a beautiful .NET Core Web API. You test it in Swagger or Postman, and it works perfectly. It returns data instantly. So, you open up your React Native Expo app, write a simple axios.get('http://localhost:5257/api/users'), press save, and... đź’Ą Network Error. If you are testing on an Android emulator or a physical device, this error will drive you crazy. Here is exactly why it happens and how to set up your environment variables to fix it forever. The Problem: What is "Localhost"? When you type localhost inside your React Native code, the code is running inside the mobile device (or emulator). To your computer, localhost means the computer itself. To your Android emulator, localhost means the Android device's internal loopback network. The emulator is literally looking inside itself for a .NET server that doesn't exist, failing, and throwing a Network Error. The Solution: The Magic IP Addresses To fix this, you need to point your mobile app to your computer's actual netwo