Modif des services avec l'utilisation d'un "BaseService"

This commit is contained in:
Sébastien André
2020-03-13 12:19:05 +01:00
parent eb799946c7
commit e7e7f3f62b
8 changed files with 95 additions and 75 deletions

View File

@@ -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));