Hi guys, i’m new in Ionic 2,
When i deploy the ionic app in android device by “ionic run android”, the post request return status: 0 for URL: null .
I don’t think that problem is with cors because i put “Access-Control-Allow-Origin *” in my backend (Node JS).
When i run with ionic serve works successfully (to work in chrome i add a plugin “Allow-Control-Allow-Origin: *”);
in index.html i add:
<meta http-equiv="Content-Security-Policy" content="default-src * data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
/*Auth Service TS */
let params = “cliente=”+JSON.stringify(credentials)
let result= this.http.post(this.httpUtil.url(this.createClienteURL),params,this.httpUtil.headers())
.map(this.httpUtil.extrairDados)
.catch(this.httpUtil.processarErros);
/* Http Utils TS */
headers() {
let headersParams = { 'Content-Type': 'application/x-www-form-urlencoded' };
if (localStorage['token']) {
headersParams['Authorization'] = localStorage['token'];
}
let headers = new Headers(headersParams);
let options = new RequestOptions({ headers: headers });
return options;
}
extrairDados(response: Response) {
let data = response.json();
return data || {};
}
processarErros(erro: any) {
console.log("error w : "+ erro);
return Observable.throw('Erro acessando servidor remoto.');
}