I have below calculate() function block where there is a function call inside an if condition to check whether an item exist using a api call.
But the method itemExistsInBasket() always returns false as the service call won't be finished and I will have to use await() to achieve this.
Could you please let me know a better way to solve the below problem.
calculate(){
     if(itemExistsInBasket()){
           // service call
     }
  }
itemExistsInBasket(){
  
    let itemExists = false;
    this._sharedService.post('API/checkItemInBask', requestBody).subscribe((res: any) => {
        itemExists = res.exists ? true : false;
    });
   return itemExists; // always returns false
}
 
     
    