Ionic 3 Http get request - null response iOS only

I’m trying to call google map api but not able to get response ;(

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

global packages:

    cordova (Cordova CLI) : 8.0.0 

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    ios-deploy : 1.9.2 
    Node       : v8.9.4
    npm        : 5.6.0 
    OS         : macOS High Sierra
    Xcode      : Xcode 9.2 Build version 9C40b 

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro

code is

  return Observable.create(observer => {
    let access: any;
    console.log('url google api ',url);
    //  let options = new RequestOptions({ headers: headers });
      this.http.get(url).timeout(25000)
        .map(res => {
          console.log('GET RESPONSE  =>', res);
          console.log('GET RESPONSE headers => ', res.headers);
    ]
          // If request fails, throw an Error that will be caught
          if (res.status < 200 || res.status >= 300) {
            throw new Error('This request has failed ' + res.status);
          }
          // If everything went fine, return the response
          else {
            console.log('GET IN SUCCESS RESPONSE ==> ');
            return res.json();
          }
        }).subscribe(data => {
          access = data;
          console.log('<== GET IN Success subscribe ==> ');
          console.log("Custome Data observer Error :+", access);
          observer.next(access);
          observer.complete();
        }, (err) => {
          console.log('<== GET IN Error subscribe ==> ');
          console.log("Custome Data observer Error :+", err);
          observer.next(false);
          observer.complete();

        });

    }).catch((error) => {
      console.log('In Observable Error => ', error);
    });

log is:
url google api https://maps.googleapis.com/maps/api/directions/json?origin=35.905414,-78.865128&destination=35.8187764,-78.6733007&mode=walking&key=xxxxxxxxxxxx

<== GET IN Error subscribe ==>
Custome Data observer Error :+ Response with status: 0 for URL: null

config.xml is

  <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />

same code work well on android.

https://forum.ionicframework.com/search?q=http%20request%20null

1 Like

@wf9a5m75 not working ;(

log is :

Google map APi url=== https://maps.googleapis.com/maps/api/directions/json?origin=35.904094,-78.86558&destination=35.8187764,-78.6733007&mode=walking&key=xxxxxx
2018-02-07 23:00:44.055021+0530 RTI[1455:305716] <== GET IN Error subscribe ==>
2018-02-07 23:00:44.056123+0530 RTI[1455:305716] Custome Data observer Error :+ Response with status: 0 for URL: null
2018-02-07 23:00:44.056585+0530 RTI[1455:305716] response google API false

Thank youuuu, saved me