Ionic 2 http call not working on android device while it working on browser. I also add cordova-whitelist-plugin and content security policy. Can you please solve this issue.
Here is my code:
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
config.xml
<access origin="*"/>
**home.ts**
import { Component } from '@angular/core';
import { Http } from '@angular/http';
import { NavController } from 'ionic-angular';
import 'rxjs/add/operator/map';
@Component({
selector: ‘page-page1’,
templateUrl: ‘page1.html’
})
export class Page1 {
apiData: any;
constructor(public navCtrl: NavController, public http: Http) {
this.getApiData();
}
getApiData() {
var response = this.http.get(‘http://192.168.56.1:4000/api/type’)
.map(res => res.json())
.subscribe(
data => {
this.apiData = data;
alert(JSON.stringify(this.apiData));
}, err => {
alert(err);
}
);
return response;
}
}