add functionality to delete employee button (#11)

Reviewed-on: #11
Reviewed-by: Hernd Beidemann <huydw@proton.me>
This commit is contained in:
2024-12-18 13:02:46 +00:00
parent e0b3d7267f
commit c39229dc94
7 changed files with 93 additions and 42 deletions

View File

@ -0,0 +1,22 @@
import {inject, Injectable} from "@angular/core";
import {HttpClient} from "@angular/common/http";
import {Observable} from "rxjs";
import {Employee} from "../Employee";
@Injectable({
providedIn: 'root'
})
export default class EmployeeApiService {
private http: HttpClient = inject(HttpClient);
private static readonly BASE_URL = 'http://localhost:8089';
public deleteById(id: number): Observable<Employee> {
return this.http.delete(`${EmployeeApiService.BASE_URL}/employees/${id}`)
}
public getAll(): Observable<Employee[]> {
return this.http.get<Employee[]>(`${EmployeeApiService.BASE_URL}/employees`)
}
}