1

I got the error while calling simple php API. This api working fine on web browser and Android devices. But problem with iOS devices. I tried all solutions but none is working. I working on latest ionic. Thanks in advance.

Error

{"headers":{"normalizedNames":{},"lazyUpdate":null,"headers":{}},"status":0,"statusText":"Unknown Error","url":"http://xxx.xxx.php/wp-json/acf/v3/options/options/series","ok":false,"name":"HttpErrorResponse","message":"Http failure response for http://xxx.xxx.php/wp-json/acf/v3/options/options/series: 0 Unknown Error","error":{"isTrusted":true}}

API Call code

this.restApiService.getData().subscribe(res => {
  for (var stateindex = 0; stateindex < res['series'].length; stateindex++) {
    this.stateList.push(res['series'][stateindex]);
  }
}, err => {
  console.log(err);
});
Maulik Patel
  • 397
  • 4
  • 15

2 Answers2

1

Finally, got the answer and issue with the link http is not secure and that's why it is not work on iOS devices but run on Android and website. So, I use https instead of http to work and get api data.

Maulik Patel
  • 397
  • 4
  • 15
1

1) CORS enable at your server side

2) If your APIs is not https, make sure android webview is not blocking the traffic. Enforce enable of cleartextTraffic, which is disabled by default. Add a security config in your app like below. Setup reference here

https://stackoverflow.com/a/57062440/7237700