I have this function in a service to get data from my API
getProductById(id) {
return this.http.get<any>(piUrl + '/id', { params: id }).catch(this.errHandler);
}
the only way i know how to get the data in my component is to subscribe like this.
this.myService.getProductById(id).subscribe(product => this.product = product);
but i just need the data once there is no stream. How can i get the data once? Something like this.
this.myService.getProductById(id).once(product => this.product = product);