108. User list service call (#13 Section 15: User service)
This commit is contained in:
@ -1,9 +1,34 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
|
import {environment} from "../../environments/environment";
|
||||||
|
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
|
||||||
|
import {Observable} from "rxjs";
|
||||||
|
import {User} from "../model/user";
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class UserService {
|
export class UserService {
|
||||||
|
|
||||||
constructor() { }
|
private host: string = environment.apiUrl;
|
||||||
|
|
||||||
|
constructor(private httpClient: HttpClient) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public getAllUsers(): Observable<UserPage | HttpErrorResponse> {
|
||||||
|
return this.httpClient
|
||||||
|
.get<UserPage>(`${this.host}/user`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserPage {
|
||||||
|
|
||||||
|
content: User[];
|
||||||
|
last: boolean;
|
||||||
|
first: boolean;
|
||||||
|
totalElements: number;
|
||||||
|
size: number;
|
||||||
|
numberOfElements: number;
|
||||||
|
number: number;
|
||||||
|
empty: boolean;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user