Initial commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { environment } from '../environments/environment';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ApiService {
|
||||
private baseUrl = environment.apiBaseUrl;
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
get<T>(path: string) {
|
||||
return this.http.get<T>(`${this.baseUrl}${path}`);
|
||||
}
|
||||
|
||||
post<T>(path: string, body: unknown) {
|
||||
return this.http.post<T>(`${this.baseUrl}${path}`, body);
|
||||
}
|
||||
|
||||
put<T>(path: string, body: unknown) {
|
||||
return this.http.put<T>(`${this.baseUrl}${path}`, body);
|
||||
}
|
||||
|
||||
delete<T>(path: string) {
|
||||
return this.http.delete<T>(`${this.baseUrl}${path}`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export const environment = {
|
||||
production: true,
|
||||
apiBaseUrl: 'http://romaric-thibault.fr:8080/api'
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
export const environment = {
|
||||
production: false,
|
||||
apiBaseUrl: 'http://localhost:8080/api'
|
||||
};
|
||||
Reference in New Issue
Block a user