Im trying to do a sum of a value od¿f an array that array is getting from a htto get method and a subscribe and im trying to show the result in the htm but dosent works
I hope somebody can help me with this coz im getting stock
here is my ts file:
result:any
getSumFacture(){
let total: number
this.http.get(this.url).subscribe((data:any) =>{
this.products = data
total = this.products.reduce((sum: any, current: { totalPrice: any; }) => sum + current.totalPrice, 0);
console.log(total);
return total
});
}
and here is my html file
{{result}}
Juan felipe Arias tabares is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.