Modif des services avec l'utilisation d'un "BaseService"
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { environment } from '../environments/environment';
|
||||
|
||||
import { GearResp, GearReq } from '../models/gear';
|
||||
|
||||
import { BaseService } from './base.service';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class GearService {
|
||||
|
||||
private readonly headers = new HttpHeaders({
|
||||
'Access-Control-Allow-Origin': environment.apiUrl
|
||||
});
|
||||
constructor(private http: HttpClient) { }
|
||||
export class GearService extends BaseService {
|
||||
constructor(private http: HttpClient) {
|
||||
super();
|
||||
}
|
||||
|
||||
public getListOfGears(): Observable<Array<GearResp>> {
|
||||
return this.http.get<Array<GearResp>>(`${environment.apiUrl}/api/Gear`, {
|
||||
return this.http.get<Array<GearResp>>(`${this.apiUrl}/Gear`, {
|
||||
headers: this.headers
|
||||
});
|
||||
}
|
||||
@@ -38,7 +38,7 @@ export class GearService {
|
||||
};
|
||||
|
||||
this.http
|
||||
.post(`${environment.apiUrl}/api/Gear`, bodyNewGear, {
|
||||
.post(`${this.apiUrl}/Gear`, bodyNewGear, {
|
||||
headers: this.headers
|
||||
})
|
||||
.subscribe(data => console.log(data));
|
||||
|
||||
Reference in New Issue
Block a user