import { Injectable } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { Observable } from 'rxjs' ; import { ENVIRONMENT } from 'src/environments/environment' ; export const SERVER_REST_URL = `${ ENVIRONMENT . apiBaseUrl }/` ; @ Injectable ( { providedIn : 'root' } ) export class HttpService { constructor ( private http ) { } public get < T > ( url , data ? , path ? ) { return this . http . get < T > ( ( path || SERVER_REST_URL ) + ( url || '' ) , { params : data || { } } ) ; } public patch < T > ( url , data ? , params ? , path ? ) { return this . http . request < T > ( 'patch' , ( path || SERVER_REST_URL ) + ( url || '' ) , { body : data , params } ) ; } public post < T > ( url , body ? , path ? , params ? ) { return this . http . post < T > ( ( path || SERVER_REST_URL ) + ( url || '' ) , body , params ) ; } public customDelete < T > ( url , options ? ) { return this . http . request < T > ( 'delete' , SERVER_REST_URL + ( url || '' ) , options ) ; } public delete < T > ( url , params ? ) { return this . http . delete < T > ( SERVER_REST_URL + ( url || '' ) , params ) ; } }