Changement pour appeler l'API C# par Angular
+ récupération des datas et leur affichage
This commit is contained in:
@@ -1,16 +1,32 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { DropZoneResp } from '../models/dropzone';
|
||||
import { JumpResp } from '../models/jump';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { tap, map } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class ServiceApi {
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
public getListOfDropZones() {
|
||||
public getListOfDropZones(): Observable<Array<DropZoneResp>> {
|
||||
const headers = new HttpHeaders({
|
||||
'Access-Control-Allow-Origin': 'https://localhost:44344',
|
||||
'Access-Control-Allow-Origin': 'http://localhost:5000',
|
||||
});
|
||||
|
||||
return this.http.get<Array<DropZoneResp>>('https://localhost:44344/api/DropZone', { headers: headers });
|
||||
return this.http.get<Array<DropZoneResp>>('http://localhost:5000/api/DropZone', { headers: headers })
|
||||
.pipe(
|
||||
map(x => x.map(data => new DropZoneResp(data))),
|
||||
// tap(event => console.log(`fetched coinrankings`)),
|
||||
// catchError(this.handleError('getCoinrankings', []))
|
||||
);
|
||||
}
|
||||
|
||||
public getListOfJumps(): Observable<Array<JumpResp>> {
|
||||
const headers = new HttpHeaders({
|
||||
'Access-Control-Allow-Origin': 'http://localhost:5000',
|
||||
});
|
||||
|
||||
return this.http.get<Array<JumpResp>>('http://localhost:5000/api/Jump', { headers: headers });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user