21 lines
560 B
TypeScript
21 lines
560 B
TypeScript
import { HttpClient } from '@angular/common/http';
|
|
import { Injectable } from '@angular/core';
|
|
import { Observable } from 'rxjs';
|
|
import { User } from '../models/user';
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class UserService {
|
|
private url = 'http://localhost:8080/api';
|
|
constructor(private http: HttpClient) {}
|
|
|
|
getUserList(): Observable<Array<User>> {
|
|
return this.http.get<User[]>(`${this.url}/users`);
|
|
}
|
|
|
|
getUserById(id: number): Observable<User> {
|
|
return this.http.get<User>(`${this.url}/user/${id}`);
|
|
}
|
|
}
|