statistic.service.ts 1.0 KB

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