The casesService function deals with handling an HTTP request and response to return a single object. However, due to its asynchronous nature, it currently returns an empty object (this.caseBook). My goal is for it to only return the object once it has been populated with a value.
public initData(selectedCaseId: number): CaseBook {
this.casesService
.GetCaseById(selectedCaseId)
.subscribe(data => {
this.caseBook = data;
});
return this.caseBook;
}