Events are now fetch from the API

This commit is contained in:
Laurent
2025-03-18 13:48:37 +01:00
parent 0554c94946
commit a056a8a921
11 changed files with 129 additions and 5 deletions

View File

@@ -0,0 +1,33 @@
import { API_PATHS } from "@/config/ApiConfig.ts";
export class EventRequests {
private readonly baseUrl: string;
private readonly endpoints;
public constructor() {
this.baseUrl = API_PATHS.BASE_URL;
this.endpoints = API_PATHS.ENDPOINTS;
}
private formatUrl(parts:string[]) : string {
let res = "";
console.log(parts)
parts.forEach((value) => {
console.log(value)
res += value.trim();
})
return res.replace(/(http|https?:\/\/[^\/]+)\/\//, '$1/');
}
public queryEvent(token : string) {
let url = this.formatUrl([this.baseUrl, this.endpoints.EVENTS, token]);
console.log(url);
fetch(url)
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
}
}