statistic.service.ts 952 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { StatisticResponse } from './../models/statisticResponse';
  2. import { Injectable } from '@angular/core';
  3. import { HttpClient, HttpHeaders } from '@angular/common/http';
  4. import { Observable } from 'rxjs';
  5. @Injectable({
  6. providedIn: 'root'
  7. })
  8. export class StatisticService {
  9. constructor(private http : HttpClient) { }
  10. // header de requete http
  11. private headers = new HttpHeaders(
  12. // { 'Access-Control-Allow-Origin':'*',
  13. // // 'Access-Control-Allow-Headers': 'X-Requested-With, Content-Type',
  14. // // {'Content-Type': 'application/json',}
  15. // // 'Access-Control-Allow-Methods': 'POST, GET',
  16. // }
  17. );
  18. // get statistic
  19. getStatistic(): Observable<StatisticResponse> {
  20. // return this.http.get<StatisticResponse>('assets/data/stat.json');
  21. const options = { headers: this.headers};
  22. let data = this.http.get<StatisticResponse>('environment.apiUrl/api/tickets/stats',options);
  23. console.log(JSON.stringify(data));
  24. return data;
  25. }
  26. }