Initial commit

This commit is contained in:
2025-11-09 10:23:23 +01:00
commit f890341ffe
34 changed files with 1058 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
import {Logger} from "../logging/logger.js";
export class Requester {
static async doGetRequest(url){
return fetch(url)
.then(async response => {
if (!response.ok) {
throw new Error(`HTTP ${response.status} ${response.statusText} : ${await response.text()}`);
}
return response.json();
})
.then(data => {
return data;
})
.catch(async error => {
await Logger.error(`Failed to fetch`, error);
throw error;
});
}
static async doPostRequest(url, headers, body){
return await fetch(url,{
method: 'POST',
headers: headers,
body: body
})
.then(response => response.json())
.then(data => {
return data;
})
.catch(error => {
Logger.error(`Unable to fetch`, error);
});
}
}