feature(database-connection): Parse dates in response
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import RequestError from "../models/RequestError";
|
||||
import UserStatsResponse from "../models/UserStatsResponse";
|
||||
import {useEffect, useState} from "react";
|
||||
|
||||
export default class UserStatsService {
|
||||
|
||||
private static apiURL = 'https://api.tsotr.humenius.me/stats'
|
||||
// private static apiURL = 'https://api.tsotr.humenius.me/stats'
|
||||
private static apiURL = 'http://localhost:3500/stats'
|
||||
|
||||
private static requestInit: RequestInit = {
|
||||
method: 'GET',
|
||||
@@ -14,9 +14,14 @@ export default class UserStatsService {
|
||||
};
|
||||
|
||||
public static async getStats(seasonId: string): Promise<UserStatsResponse> {
|
||||
return fetch(this.apiURL, this.requestInit)
|
||||
return fetch(`${this.apiURL}/season/${seasonId}`, this.requestInit)
|
||||
.then(res => UserStatsService.checkResponse(res))
|
||||
.then(data => data.json());
|
||||
.then(data => data.json())
|
||||
.then(data => {
|
||||
data.dates.start = new Date(data.dates.start)
|
||||
data.dates.end = new Date(data.dates.end)
|
||||
return data
|
||||
})
|
||||
}
|
||||
|
||||
private static checkResponse(response: any): any {
|
||||
|
||||
Reference in New Issue
Block a user