$http works in browser but not in IOS Emulator

Hi guys, going round in circles on this one…

Here are the response codes when testing in chrome via ionic serve:

  • works in ionic serve
  • does not work in xcode emulator
  • pulling data from a live server with “Access-Control-Allow-Origin: *”
  • can access the live server from Safari inside the Emulator

From the xcode debug console I can see the $http is getting a status:0 response:

RROR: ERR {“data”:null,“status”:0,“config”:{“method”:“GET”,“transformRequest”:[null],“transformResponse”:[null],“url”:“my-url-is-here”,“headers”:{“Accept”:“application/json, text/plain, /”}},“statusText”:""}

Any suggestions?

Hi, are your making a http (not https) request in iOS 9 emulator? If so, it is because iOS 9 requires https for all hosts you request data from unless you specify exception domains in your app’s Info.plist file. If your app needs to connect to arbitrary hosts, you can add these lines to Info.plist file:

    <!--Connect to anything (this is probably BAD)-->

Thanks zhushijie,
That was it. Have added to my .plist and it works, will look to adding ssl v soon!