import { HttpClient } from '@angular/common/http' ; import { Injectable } from '@angular/core' ; import { CatModel , ICreateCatDto } from '@api-interface' ; import { Observable } from 'rxjs' ; @ Injectable ( ) export class CatsService { private apiUrl = 'http://localhost:3000' ; constructor ( private http ) { } getAll ( ) { return this . http . get < CatModel [ ] > ( `${ this . apiUrl }/cats` ) ; } getById ( id ) { return this . http . get < CatModel > ( `${ this . apiUrl }/cats/${ id }` ) ; } create ( createCatDto ) { return this . http . post < CatModel > ( `${ this . apiUrl }/cats` , createCatDto ) ; } delete ( id ) { return this . http . delete < CatModel > ( `${ this . apiUrl }/cats/${ id }` ) ; } }