如何解决错误代码:0,Android上的消息HTTP失败-IONIC API [英] How to solve Error Code: 0, Message HTTP failure on android - IONIC API

查看:102
本文介绍了如何解决错误代码:0,Android上的消息HTTP失败-IONIC API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在浏览器上访问我的应用程序时,从API访问数据没有问题.但是,当我在android studio的模拟器上启动它时,我做不到.它会弹出带有错误代码:0的卡,并带有引用链接API的消息提示失败.

When i accessed my app on the browser i have no problem accessing data from API. But when i launch it on emulator on android studio, i can´t. It pops-up a card with a ERROR CODE :0, Message Ht failure with the referent link API.

我试图添加允许意图,将API GET请求上的"localhost"更改为"127.0.0.1" ...以及我不记得的更多内容.

I tried to add the allow-intent, change the "localhost" on API GET request to "127.0.0.1"... and more that i don't remember.

即使服务器端接收到的数据也无法访问.现在,我倾向于认为这是代理相关的问题或CORS问题.

Even the DATA received by the server side is not accessible. Right now i'm inclined to think that is a proxy related issue or a CORS problem.

推荐答案

已解决的问题:基本上,您需要在要提供服务的项目上更改URL.将其从 localhost:3000 更改为 10.0.2.2:3000 . 3000 是端口号,不需要为 3000 .然后,您打开android studio,打开模拟器并运行它.在android设备旁边的litle选项卡上,末尾有3个点.按下这些键,然后进入设置,并将proxy更改为 10.0.2.2 ,并将端口号更改为您正在使用的端口号,在本例中为 3000 .之后,它将起作用.对不起,关于该问题的最新更新!有关更多信息:

Problem Solved: Basically you need to change the url on your project where you do service. Change it from localhost:3000 to 10.0.2.2:3000. The 3000is the port's number, it doesn't need to be 3000. Then you open android studio, open emulator and run it. On the litle tab right next to the android device, theres 3 dots at the end. Press those, then go to settings, and change proxy to 10.0.2.2 and the port number to the one you are using, in this case is 3000. After that it will work. Sorry for late update on the problem! For more info: why do we use 10.0.2.2 to connect to local web server instead of using computer ip address in android client

这篇关于如何解决错误代码:0,Android上的消息HTTP失败-IONIC API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆