I have this function :
async useLoyaltyCard(orderTest,bill) {
let restaurantKey;
let database = firebase.database();
let restaurantData;
let loyaltyUseValue;
let loyaltyCardType;
const snapshot = await database.ref('/restaurant/' + orderTest.restaurantKey ).once('value');
restaurantData = snapshot.val();
loyaltyCardType = restaurantData.loyaltyCard.type.cardType;
if(loyaltyCardType ==="discount"){
console.log("TIPO DISCONTO");
}
if(loyaltyCardType ==="free"){
console.log("TIPO FREE");
bill = 0;
}
if(loyaltyCardType ==="points"){
console.log("TIPO POINTS");
}
return bill;
}
That should return a value of 0.
I have this on a button :
(click)="bill = this.loyaltyCardService.useLoyaltyCard(this.order,this.bill)
That is the call of the function and the use of it.
But i get this error " Assigned expression type Promise is not assignable to type numbe"
I dont know where i got the promise or what should i add to make it work
the return value is a number so i dont know why i am getting this error