fix: correct events endpoint path and error body handling

This commit is contained in:
Prox 2026-03-04 00:01:38 +02:00
parent 0e2d828bd4
commit f9ccf1860b

View File

@ -65,11 +65,12 @@ export class NetbirdClient {
}); });
if (!resp.ok) { if (!resp.ok) {
const text = await resp.text();
let errorBody: unknown; let errorBody: unknown;
try { try {
errorBody = await resp.json(); errorBody = JSON.parse(text);
} catch { } catch {
errorBody = await resp.text(); errorBody = text;
} }
throw new NetbirdApiError(resp.status, method, path, errorBody); throw new NetbirdApiError(resp.status, method, path, errorBody);
} }
@ -123,7 +124,7 @@ export class NetbirdClient {
return this.request("POST", "/setup-keys", data); return this.request("POST", "/setup-keys", data);
} }
deleteSetupKey(id: number): Promise<void> { deleteSetupKey(id: number | string): Promise<void> {
return this.request("DELETE", `/setup-keys/${id}`); return this.request("DELETE", `/setup-keys/${id}`);
} }
@ -220,6 +221,6 @@ export class NetbirdClient {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
listEvents(): Promise<NbEvent[]> { listEvents(): Promise<NbEvent[]> {
return this.request("GET", "/events"); return this.request("GET", "/events/audit");
} }
} }