import { Injectable } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { environment } from '@environments/environment' ; import { User } from '@app/_models' ; @ Injectable ( { providedIn : 'root' } ) export class UserService { constructor ( private http ) { } getAll ( ) { return this . http . get < User [ ] > ( `${ environment . apiUrl }/users` ) ; } getById ( id ) { return this . http . get ( `${ environment . apiUrl }/users/${ id }` ) ; } register ( user ) { return this . http . post ( `${ environment . apiUrl }/users/register` , user ) ; } update ( user ) { return this . http . put ( `${ environment . apiUrl }/users/${ user . id }` , user ) ; } delete ( id ) { return this . http . delete ( `${ environment . apiUrl }/users/${ id }` ) ; } }