18 lines
532 B
TypeScript
18 lines
532 B
TypeScript
import { HttpClient } from '@angular/common/http';
|
|
import { inject, Service } from '@angular/core';
|
|
import { Observable } from 'rxjs';
|
|
|
|
@Service()
|
|
export class BaseService {
|
|
private readonly http: HttpClient = inject(HttpClient);
|
|
private readonly baseAddress: string = "http://127.0.0.1:8080/";
|
|
|
|
protected get<T>(url: string): Observable<T> {
|
|
return this.http.get<T>(this.baseAddress + url);
|
|
}
|
|
|
|
protected post<T>(url: string, body: T): Observable<T> {
|
|
return this.http.post<T>(this.baseAddress + url, body);
|
|
}
|
|
}
|