简体   繁体   English

React Native API 调用 .NET 核心后端仅在启用 React Native 调试器网络检查时工作

[英]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.

相关问题 当连接@microsoft/signalr 与 .net 核心 api 反应本机时无法设置 wss:// - Unable to set wss:// when connect @microsoft/signalr in react native with .net core api React Native:为什么将查询参数附加到我的 .Net API 调用会自动返回 404 错误? - React Native: Why does appending query parameters to my .Net API calls automatically return a 404 error? 从 React Native 访问 ASP.NET Core 2.1 Web API 时“无法对 HTTPS 连接进行身份验证” - 'Failed to authenticate HTTPS connection' while accessing ASP.NET Core 2.1 Web API from React Native 启动新的 react-native 项目时找不到 .Net 核心 - Can't find .Net core when starting a new react-native project 无法将Android React Native应用程序连接到localHost .NET API - Cannot connect android React Native app to localHost .NET api 检查/反汇编.Net本机映像 - Inspect / disassemble .Net native images 有没有办法在 React Native 中使用任何 .net dll ? - Is there a way to use any .net dll in React Native? React Native:调用在本地主机上运行的 API - React Native: Calling API running on localhost native dll调用.NET dll - native dll calls a .NET dll 终止调用本机代码的.Net线程 - Terminate .Net thread which calls native Code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM