Friends,
I am using web service and forms for a number of situations in my project. But now when I try to use same strategy the data is not provided by the provider function. It gives ‘null’ value always. But I can see the value in chrome web console.
page.ts (controller)
call function this.getYearMaster(); in constructor
my controller function is
getYearMaster() {
this.projectplanprovider.getYearMaster()
.then(data => {
this.year = data;
//console.log(this.data);
alert("hi: "+this.year);
});
}
my provider function is
public getYearMaster() {
const obj = {wsname: 'YearMaster' };
const myData = JSON.stringify(obj);
return new Promise((resolve, reject) => {
console.log('will call the web service');
const url = 'http://apps.xxx.gov.in/mobservice/index.php/yyy/';
this.http.post(url, myData, { headers: new HttpHeaders(), responseType: 'json'})
/*.map(res => {
console.log('res1', res);
return res; // is this map needed, when it is returning the same value?
})*/
.subscribe(
res => {
console.log('res2', res);
resolve(res);
},
(err) => {
console.log('oops some error in Project Financial year selection');
reject(err);
}
);
});
}
But I get on 'null' value as response ..
please advise
Thanks
Anes