-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.service.ts
39 lines (28 loc) · 1015 Bytes
/
user.service.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { Injectable } from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Observable} from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class UserService {
private baseUrl='http://localhost:8080/user';
constructor(private http : HttpClient) { }
createUser(user: Object): Observable<Object> {
return this.http.post(`${this.baseUrl}` + `/create`, user);
}
getUser(id: number): Observable<Object> {
return this.http.get(`${this.baseUrl}`+`/get/${id}`);
}
getUsersList(): Observable<any> {
return this.http.get(`${this.baseUrl}`+`/get`);
}
deleteUser(id: number): Observable<any> {
return this.http.delete(`${this.baseUrl}`+`/delete/${id}`, { responseType: 'text' });
}
deleteAll(): Observable<any> {
return this.http.delete(`${this.baseUrl}` + `/deleteAll`, { responseType: 'text' });
}
updateUser(id: number, value: any): Observable<Object> {
return this.http.put(`${this.baseUrl}`+`/update/${id}`, value);
}
}