import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; @Injectable({ providedIn: 'root' }) export class ApiService { server_route = 'http://localhost:3000' constructor(private http: HttpClient) { } getMessage() { return this.http.get( 'http://localhost:3000/api/message'); } postReplayUpload(file: any) { return this.http.post( this.server_route+'/api/upload-replay', file); } getSeasons() { return this.http.get( this.server_route+'/api/seasons'); } getSeasonDetails(id: string) { return this.http.get( this.server_route+'/api/seasons/'+id); } addSeason(title: string, subtitle: string, startDate: Date) { return this.http.post<{title: string, subtitle: string, startDate: Date}>(this.server_route+'/api/seasons/add', { title, subtitle, startDate }, {headers: { authorization: `Bearer ${localStorage.getItem('token')}` },}); } addRace(seasonId: string, startDate: Date, endDate: Date, mapName: string, mapLink: string, weekNumber: Number) { return this.http.post<{title: string, subtitle: string, startDate: Date}>(this.server_route+'/api/race/add', { seasonId, startDate, endDate, mapName, mapLink, weekNumber }, {headers: { authorization: `Bearer ${localStorage.getItem('token')}` },}); } }