我在调用简单的php时得到了错误。这个api在web浏览器和Android设备上运行得很好。但是iOS设备有问题。我尝试了所有的解决方案,但都没有奏效。我在研究最新的离子。提前谢谢。
误差
{"headers":{"normalizedNames":{},"lazyUpdate":null,“headers”:{},"status":0,“statusText”:“未知错误”,"url":"http://xxx.xxx.php/wp-json/acf/v3/options/options/series","ok":false,"name":"HttpErrorResponse",“message”:“http://xxx.xxx.php/wp-json/acf/v3/options/options/series:0未知错误的Http失败响应”,“statusText:{”isTrusted“:true}}
API调用代码
this.restApiService.getData().subscribe(res => {
for (var stateindex = 0; stateindex < res['series'].length; stateindex++) {
this.stateList.push(res['series'][stateindex]);
}
}, err => {
console.log(err);
});发布于 2019-06-24 00:30:18
最后,得到了链接的答案和问题,是不安全的,这就是为什么它不是在iOS设备上工作,而是运行在安卓和网站上。因此,我使用https而不是http来工作和获取api数据。
发布于 2019-11-12 15:52:15
1)在服务器端启用CORS
2)如果您的API不是https,请确保android没有阻塞流量。强制启用cleartextTraffic,默认情况下是禁用的。在应用程序中添加一个安全配置,如下所示。这里的设置参考
https://stackoverflow.com/questions/56640452
复制相似问题