Fix web api client (#3779)

This commit is contained in:
Anbraten 2024-06-10 12:13:13 +02:00 committed by GitHub
parent 7cae6e58f8
commit 9bc15a5f3b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -40,7 +40,7 @@ export default class ApiClient {
this.csrf = csrf; this.csrf = csrf;
} }
private async _request(method: string, path: string, data: unknown): Promise<unknown> { private async _request(method: string, path: string, data?: unknown): Promise<unknown> {
const res = await fetch(`${this.server}${path}`, { const res = await fetch(`${this.server}${path}`, {
method, method,
headers: { headers: {
@ -71,7 +71,7 @@ export default class ApiClient {
} }
_get(path: string) { _get(path: string) {
return this._request('GET', path, null); return this._request('GET', path);
} }
_post(path: string, data?: unknown) { _post(path: string, data?: unknown) {
@ -83,7 +83,7 @@ export default class ApiClient {
} }
_delete(path: string) { _delete(path: string) {
return this._request('DELETE', path, null); return this._request('DELETE', path);
} }
_subscribe<T>(path: string, callback: (data: T) => void, opts = { reconnect: true }) { _subscribe<T>(path: string, callback: (data: T) => void, opts = { reconnect: true }) {