网络请求在响应本机博览会时失败 [英] Network request failed in react native expo
问题描述
我在 react native 中使用 expo.我在将数据发布到 api laravel 时遇到问题.它说网络请求失败".这是我的代码:
im using expo in react native.i have a problem when post data to api laravel.its say"Network Request Failed".heres my code:
我希望你们能帮助我谢谢你们.在这里输入图片描述>
i hope you can help me guys thankyou.enter image description here
推荐答案
我发现您的 fetch URL
是使用 HTTP 端点提供的.您只能从 react-native 项目向 HTTPS 端点发出请求.
I see that your fetch URL
is served using an HTTP endpoint. You can only make requests to HTTPS endpoints from react-native projects.
一种可能的解决方法是使用 ngrok.只需下载并运行:
A possible workaround is to use ngrok. Just download it and run:
./ngrok http 8000
因为您的端口号是 8000.它会公开一个 HTTPS 端点并用该链接替换您的 fetch URL
并尝试再次获取数据
Since your port number is 8000. It will expose an HTTPS endpoint and replace your fetch URL
with that link and try fetching the data again
这篇关于网络请求在响应本机博览会时失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!