generated from bisco/codex-bootstrap
feat: load shows from frontend API
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { API_BASE_URL } from './api-config.token';
|
||||
|
||||
export type ShowListItem = {
|
||||
id: number;
|
||||
title: string;
|
||||
slug: string;
|
||||
summary: string;
|
||||
poster_image: string;
|
||||
};
|
||||
|
||||
type ShowListResponse = {
|
||||
results: ShowListItem[];
|
||||
};
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ShowsApiService {
|
||||
private readonly http = inject(HttpClient);
|
||||
private readonly apiBaseUrl = inject(API_BASE_URL);
|
||||
|
||||
listShows(): Observable<ShowListResponse> {
|
||||
return this.http.get<ShowListResponse>(`${this.apiBaseUrl}/shows/`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user