Files
ts-onlinetime-ranks/frontend/src/services/UserStatsService.ts
Humenius aa1c3d1464
Some checks failed
continuous-integration/drone/push Build is failing
Clean up code and add logging framework for backend
2020-06-02 10:33:59 +02:00

27 lines
590 B
TypeScript

import TableEntry from "../models/TableEntry";
export default class UserStatsService {
private apiURL = 'https://api.tsotr.humenius.me/stats'
private requestInit: RequestInit = {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
};
async getStats(): Promise<TableEntry[]> {
return fetch(this.apiURL, this.requestInit)
.then(res => this.checkResponse(res))
.then(data => data.json())
}
private checkResponse(response: any): any {
if (!response.ok) {
throw Error(response.statusText);
}
return response;
}
}