I'm having trouble retrieving the correct data from an observable in my project. Here is the code for my API call:
getLastxScans(amount: number): Observable<Scan[]> {
return this.http.get<Scan[]>(`${this.ROOT_URL}/Scan/amount/${amount}`);
}
When I subscribe to the above call, it returns:
{scans: Array(30)}
However, when I try to store this data in a Scan[] array, it doesn't work as expected. Do I need to access the nested data inside the object? If so, how can I achieve this? Here are the two ways I have tried:
this.deviceService.getLastxScans(this.scanAmount)
.subscribe(scans => this.scans = scans);
And also tried:
this.deviceService.getLastxScans(this.scanAmount)
.subscribe(res => this.scans = res.scans);