I would like to form result of http call as result of method. For example:
Code with error:
getPersonId(idBook: number): number {
return this.mpShipmentWebAPI
.GetLast({ bookID: idBook })
.subscribe((books) => {
return Number(books.Data[0].ID);
});
}
I know how to fix the above code:
getPersonId(idBook: number): number {
return this.mpShipmentWebAPI
.GetLast({ bookID: idBook })
.subscribe((books) => {
this.handleData(books),
});
}
What I want is to check result of this in the following manner:
let idPerson = this.getPersonId(idBook);
if (idPerson > 0) {
//the rest code here
}
Is it possible to do?