diff options
author | sowgro <tpoke.ferrari@gmail.com> | 2025-02-26 20:41:35 -0500 |
---|---|---|
committer | sowgro <tpoke.ferrari@gmail.com> | 2025-02-26 20:41:35 -0500 |
commit | 8a2d6c332a089c2dbb7351514499e16f343959ff (patch) | |
tree | 9451b9a92b8fc43ed88d215fd3b8a63a151f12f7 /ufund-ui/src/app/services/users.service.ts | |
parent | 04910f9a8e8b30add77852ac2968acdbda834a83 (diff) | |
download | JellySolutions-8a2d6c332a089c2dbb7351514499e16f343959ff.tar.gz JellySolutions-8a2d6c332a089c2dbb7351514499e16f343959ff.tar.bz2 JellySolutions-8a2d6c332a089c2dbb7351514499e16f343959ff.zip |
Start services and organize project
Diffstat (limited to 'ufund-ui/src/app/services/users.service.ts')
-rw-r--r-- | ufund-ui/src/app/services/users.service.ts | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/ufund-ui/src/app/services/users.service.ts b/ufund-ui/src/app/services/users.service.ts new file mode 100644 index 0000000..65a9e61 --- /dev/null +++ b/ufund-ui/src/app/services/users.service.ts @@ -0,0 +1,35 @@ +import { Injectable } from '@angular/core'; +import {HttpClient, HttpHeaders} from '@angular/common/http'; +import {Observable} from 'rxjs'; +import {User} from '../models/User'; + +@Injectable({ + providedIn: 'root' +}) +export class UsersService { + + private url = "localhost:8080/cupboard" + private httpOptions = { + headers: new HttpHeaders({'Content-Type': 'application/json'}) + }; + + constructor( + private http: HttpClient + ) {} + + createUser(data: User): Observable<User> { + return this.http.post<User>(this.url, data, this.httpOptions) + } + + getUser(id: number): Observable<User> { + return this.http.get<User>(`${this.url}/${id}`, this.httpOptions) + } + + updateUser(id: number): Observable<User> { + return this.http.put<User>(`${this.url}/${id}`, this.httpOptions) + } + + deleteUser(id: number): Observable<boolean> { + return this.http.delete<boolean>(`${this.url}/${id}`, this.httpOptions) + } +} |