Fix API return type mismatch
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
interface GetConsumptionEntriesResponse {
|
||||
consumptions: ConsumptionEntry[];
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
@if (consumptionEntries$ | async; as consumptionEntries) {
|
||||
<div>
|
||||
<div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -18,5 +18,5 @@
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { AsyncPipe, DatePipe } from '@angular/common';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { Observable, tap } from 'rxjs';
|
||||
import { map, Observable, tap } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'app-entries',
|
||||
@@ -16,12 +16,13 @@ export class EntriesComponent {
|
||||
protected readonly consumptionEntries$: Observable<ConsumptionEntry[]>;
|
||||
|
||||
constructor() {
|
||||
this.consumptionEntries$ = this.http.get<ConsumptionEntry[]>('/api/v1/consumptions')
|
||||
this.consumptionEntries$ = this.http.get<GetConsumptionEntriesResponse>('/api/v1/consumptions')
|
||||
.pipe(
|
||||
takeUntilDestroyed(),
|
||||
tap((response) => {
|
||||
console.log('Entries response:', response);
|
||||
}),
|
||||
map(response => response.consumptions)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user