I've been banging my head against this one trying to figure it out, and no amount of documentation I've been able to read has given me an answer to my question.
I have a service which is speaking directly to an API and returning an observable event which under normal circumstances I would subscribe to and do what I want with the data, however in a secondary service which utilizes the requests from the restful service, I need to be able to return values from the request.
getSomething() {
return this._restService.addRequest('object', 'method').run()
.subscribe(
res => {
res;
},
err => {
console.error(err);
}
);
}
returnSomething() {
return this.getSomething();
}
In the quick example above, I want to know if there is any way I can return res
from getSomething()
within returnSomething()
. If it's not achievable in this way, what is the alternative? I will add that the _restService is pretty heavily relied upon and I don't really want to start messing with that.