[英]React Native API Calls to .NET Core backend only work when React Native Debugger Network Inspect Enabled
I am creating a project with a React Native front end and a .NET Core backend.我正在创建一个带有 React Native 前端和 .NET Core 后端的项目。 Right now I am using Visual Studio to run the backend server, and the base URL for the API calls is
https://localhost:5001
.现在我正在使用 Visual Studio 运行后端服务器,API 调用的基础 URL 是
https://localhost:5001
。 I am testing on an Android Emulator with Android Studio.我正在使用 Android Studio 在 Android 仿真器上进行测试。 The problem is that the API calls will only work when the React Native Debugger network inspect feature is enabled.
问题是 API 调用仅在启用 React Native Debugger 网络检查功能时才有效。 Other than that, it just gives me
Error: Network Error
in the console.除此之外,它只是给我
Error: Network Error
。 I have tried putting my own IP address instead of localhost
, as well as trying to change localhost
to 10.0.2.2
.我尝试使用自己的 IP 地址代替
localhost
,并尝试将localhost
更改为10.0.2.2
。 Neither of those work.这些都不起作用。 Does anyone know of a fix for this issue?
有谁知道这个问题的解决方法?
You did your call with axios?你打电话给 axios? if yes try to use fetch i think the problem comes with https
如果是,请尝试使用 fetch 我认为问题出在 https
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.