I'm using Angular 6.
I'm calling the service(service2) getData from another service(service 1). The post request is successful in the service2 and prints out the data to the console. However, the data is not returned to service1 which is calling service2 and 'result' object is always undefined.
Calling service (service1)
this.service.getData(id, token).then(
result => {
console.log("result " + result);
},
error => {
console.log("error " + error);
});
Service (service2)
getData(id, token): Promise < any > {
var startTime: number = new Date().getTime();
return new Promise < any > ((resolve, reject) => {
this.http.post(url, soapMessage, {
headers: new HttpHeaders().set('Content-Type', 'text/xml'),
responseType: 'text'
}).toPromise().then(
res => { // Success
resolve();
console.log(res);
//return res;
},
msg => { // Error
}
);
});
}
resobject to the resolve method. - Shane