add functionality to delete employee button (#11)
Reviewed-on: #11 Reviewed-by: Hernd Beidemann <huydw@proton.me>
This commit is contained in:
22
src/app/services/employee-api.service.ts
Normal file
22
src/app/services/employee-api.service.ts
Normal 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`)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user