[ionic 4] Http get works only in browser

hi, i have a problem with http get that does not work on android but it works on ios and browser, I am on ionic 4 , this is my code

import { Http, Headers, RequestOptions} from ‘@angular/http’;
const url = ‘http://het.ma/webservice.php’;
this.http.get(url + ‘?login=’ + this.logindata.login + ‘&pass=’ + this.logindata.pass)
.pipe(map(res => res.json()))
.subscribe(data => {
if (data.analyses != null) {
const navigationExtras: NavigationExtras = {
queryParams: {
special: JSON.stringify(data.analyses),
}
};
console.log(‘erreur:’, navigationExtras);
this.router.navigate([‘resultats’], navigationExtras);
}
}, err => {
console.log (err);
});
my system info:
Ionic:

Ionic CLI : 5.2.3 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.7.4
@angular-devkit/build-angular : 0.801.3
@angular-devkit/schematics : 8.1.3
@angular/cli : 8.1.3
@ionic/angular-toolkit : 2.0.0

Capacitor:

Capacitor CLI : 1.1.1
@capacitor/core : 1.1.1

Cordova:

Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.0.0, ios 5.0.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.1, (and 10 other plugins)

Utility:

cordova-res : 0.6.0
native-run : 0.2.8

System:

Android SDK Tools : 26.1.1 (/Users/re/Library/Android/sdk)
ios-deploy : 2.0.0
ios-sim : 8.0.2
NodeJS : v10.12.0 (/usr/local/bin/node)
npm : 6.9.2
OS : macOS Mojave
Xcode : Xcode 10.3 Build version 10G8

Try using https:// endpoints instead of http:// ones.

I did not understand your answer

Android 9 is blocking any request over http as default. I just fixed this same problem yesterday in one of my apps. Check this post

1 Like

thank you very much your solution helped me to solve my problem, but I have another problem, I have a file to download on android it blocks, I use FileOpener2

Can’t help much there, I am afraid.