import { StatisticResponse } from './../models/statisticResponse'; import { environment } from 'src/environments/environment'; import { Injectable } from '@angular/core'; import { HttpClient, HttpHeaders } from '@angular/common/http'; import { Observable } from 'rxjs'; @Injectable({ providedIn: 'root' }) export class StatisticService { private apiUrl = environment.apiUrl constructor(private http : HttpClient) { } // header de requete http private headers = new HttpHeaders( // { 'Access-Control-Allow-Origin':'*', // // 'Access-Control-Allow-Headers': 'X-Requested-With, Content-Type', // // {'Content-Type': 'application/json',} // // 'Access-Control-Allow-Methods': 'POST, GET', // } ); // get statistic getStatistic(): Observable { // return this.http.get('assets/data/stat.json'); const options = { headers: this.headers}; let data = this.http.get('http://localhost:4000/api/tickets/stats',options); console.log(JSON.stringify(data)); return data; } }