Https post not working on iOS


#1

Hi,

I am using the following code to send a post request to my API which is working fine within the browser (with CORS disabled) and on a native Android build. However the same code built for iOS doesn’t work. The code is below:

return new Promise((resolve, reject) => {
      this.http.post(this.apiUrl+'/login/', data)
        .subscribe(res => {
          resolve(res);
        }, (err) => {
          reject(err);
        });
    });

The output I see within Xcode when running the app is:

{"headers":{"normalizedNames":{},"lazyUpdate":null,"headers":{}},"status":0,"statusText":"Unknown Error","url":null,"ok":false,"name":"HttpErrorResponse","message":"Http failure response for (unknown url): 0 Unknown Error","error":{"isTrusted":true}}

If I load my app via phone gap on iOS the API calls work fine, but fail when built via xcode and also when running via ionic view.


#2

There is no point in explicitly instantiating a Promise in this situation.


#3

same here, works on android build and browser but never work on ios. any fix on this?