27 lines
590 B
TypeScript
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;
|
|
}
|
|
}
|