i have an array and i'm trying to return the status title from the largest id in that array using Angular. Here's a link to the image: https://i.sstatic.net/87okc.png
I've updated my code as follows:
getData(id){
let url_detail = this.apiurl + `/${id}`;
this.http.get<any[]>(url_detail).pipe(
tap(data=>{
var status = data.reduce((item, curr) => {
return item.id < curr.id ? curr : item;
}).status.title;
return status;
}),
catchError(this.handleError)
);
}
However, when I call this function like this:
console.log("status ", this.service.getData(1))
it only returns undefined. Can someone please assist me with this issue?