0

i followed this Tutorial https://www.freecodecamp.org/news/how-to-build-your-first-ionic-4-app-with-api-calls-f6ea747dc17a/ trying to learn Ionic and dealing with HTTP . it works perfectly fine on browser . but after building an APK using " ionic cordova build android " the app stop sending HTTP get requests.

1 Answer 1

1

You should try this native plugin :

import { HTTP } from '@ionic-native/http';

instead of

import { HttpClient } from '@angular/common/http';

In ionic 4, you will have to do something like :

import { http } from '@ionic-native/http';

this.http.get("URL", {}, {})
  .then(data => {
    console.log(data.status);
    console.log(data.data); // data received by server
    console.log(data.headers);
  })
  .catch(error => {
    console.log(error.status);
    console.log(error.error); // error message as string
    console.log(error.headers);
  });

As you see, this is quite similar.

Learn more about it here : https://ionicframework.com/docs/v3/native/http/

Not the answer you're looking for? Browse other questions tagged or ask your own question.