I’m having problems to test my app into Ionic DevApp (Android and iPhone). At Chrome it works fine, no errors, but when I try execute it into Ionic DevApp, on first call to http.get results the following error:
[app-scripts] [09:16:12] console.warn: (getRootNav) is deprecated and will be removed in the next major release. Use getRootNavById
[app-scripts] instead.
[app-scripts] [09:16:12] console.log: {"message":"Failed to read the 'responseXML' property from 'XMLHttpRequest': The value is only
[app-scripts] accessible if the object's 'responseType' is '' or 'document' (was
[app-scripts] 'text').","name":"InvalidStateError","code":11,"stack":"Error: Failed to read the 'responseXML' property
[app-scripts] from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'document' (was
[app-scripts] 'text').\n at Object.stringify (native)\n at Object.R.stringify
[app-scripts] (http://192.168.0.100:8100/build/polyfills.js:1:30818)\n at Object.stringify
[app-scripts] (http://192.168.0.100:8100/build/vendor.js:143878:23)\n at http://192.168.0.100:8100/build/main.js:93:34\n
[app-scripts] at t.invoke (http://192.168.0.100:8100/build/polyfills.js:3:14976)\n at r.run
[app-scripts] (http://192.168.0.100:8100/build/polyfills.js:3:10143)\n at
[app-scripts] http://192.168.0.100:8100/build/polyfills.js:3:20242\n at t.invokeTask
[app-scripts] (http://192.168.0.100:8100/build/polyfills.js:3:15660)\n at r.runTask
[app-scripts] (http://192.168.0.100:8100/build/polyfills.js:3:10834)\n at o
[app-scripts] (http://192.168.0.100:8100/build/polyfills.js:3:7894)","__zone_symbol__currentTask":{"type":"microTask","state":"notScheduled","source":"Promise.then","zone":"<root>","cancelFn":null,"runCount":0}}
I am using the following code:
export class RestProvider {
...
getData2(token:string, uri:string): Observable<any> {
let url:string = this.apiUrl + uri;
let headers:HttpHeaders = new HttpHeaders({
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
});
return this.http.get<any>(url, { headers: headers })
.timeout(18000)
.retry(3);
}
...
}
export class MyApplicationPage {
...
myMethod(token:string) {
this.restProvider.getData2(token, uri)
.map((data:any) => data)
.catch((error:any) => Observable.throw(error))
.subscribe(
data => {
if (data !== null) {
this.customer_data = data['results'][0];
} else {
this.alert('Error', 'Customer not found');
}
},
error => {
this.alert(error.statusText, error.message);
// the above error message is presented by the following line
console.log( JSON.stringfy(error) );
}
);
}
}
Just remembering, all this code works fine except into Ionic DevApp when the console.log presents the above error. Any idea?