Http requests not working on root page


#1

Hi everyone, it’s been several days since I have a problem with my ionic project and I have not found a solution yet.

I explain briefly and roughly what the app consists of:
It consists of several pages, each one has its own list (ion-list) that is populated via an https call to a remote server. The pages are accessible via the side menu. So far everything is ok.
The root page also makes several calls to populate the different components, but here’s the problem. When I start the app with the run command or compile the apk (regarding Android) with “ionic cordova build android”, the app works perfectly. However, when I run the app in production with “ionic cordova build android -prod -release” the root page will no longer make http calls. The other pages, when opened via the menu, work perfectly.

The strange thing is that if I compile the apk with “ionic cordova build android -release” so without the -prod flag then the root page makes the calls.
On ios, on the other hand, he never performs them (neither in debug nor in production).

Root page:

  ngOnInit(){
    this.getEvents();
  }

getEvents() {
    this.http.get('my url', {}, {})
    .then(data => {
      console.log(JSON.parse(data.data));
      this.events = JSON.parse(data.data);
    })
    .catch(error => {

      console.log(error.status);
      console.log(error.error); // error message as string
      console.log(error.headers);

    });
  }

Ionic info:

Ionic:

   ionic (Ionic CLI)  : 4.5.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.0

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.0.0, ios 4.5.5, ios_backup 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 2.1.4, (and 12 other plugins)

System:

   NodeJS : v10.12.0 (/usr/local/Cellar/node/10.12.0/bin/node)
   npm    : 6.4.1
   OS     : macOS Mojave
   Xcode  : Xcode 10.1 Build version 10B61

PS. I apologize for my English but it’s not my native language.