Reputation: 545
On calling my web service from my app.component.ts file I am getting the below error when I run the app in VS Emulator for Android. Can someone please provide a solution?
In the ngOnInit() life cycle hook of app.component.ts I am accessing the data from the web service class
app.component.ts(excerpt)
ngOnInit()
{
this.myDataService.openWebMwthod()
.subscribe((response)=>{
this.datas = response;
JSON.stringify(this.datas);
alert("here"+this.datas);
if(this.datas == null || this.datas == "")
{
this.nav.setRoot(this.accessDeniedPage, {showFooter : false});
}
else
{
this.nav.setRoot(this.homePage, {showFooter : false});
}
});
}
Below is my Web Service class excerpt where I am making a REST call:
my-mobile.dataservice(excerpt)
public openWebMwthod() : Observable<any>{
this.initializeApp();
let details = {
"EmpID" : this.sapId
};
let body = JSON.stringify(details);
let headers = new Headers(
{
'Content-Type': 'application/json',
}
);
let options = new RequestOptions({headers:headers});
return this.http.post(URL,body,options)
.map( (res) => res.json())
}
Upvotes: 1
Views: 1978
Reputation: 8726
Just add this code to your config.xml
<preference name="loadUrlTimeoutValue" value="700000" />
Upvotes: 2