diff --git a/src/netbird/client.ts b/src/netbird/client.ts index e6f162e..e2ccd25 100644 --- a/src/netbird/client.ts +++ b/src/netbird/client.ts @@ -65,11 +65,12 @@ export class NetbirdClient { }); if (!resp.ok) { + const text = await resp.text(); let errorBody: unknown; try { - errorBody = await resp.json(); + errorBody = JSON.parse(text); } catch { - errorBody = await resp.text(); + errorBody = text; } throw new NetbirdApiError(resp.status, method, path, errorBody); } @@ -123,7 +124,7 @@ export class NetbirdClient { return this.request("POST", "/setup-keys", data); } - deleteSetupKey(id: number): Promise { + deleteSetupKey(id: number | string): Promise { return this.request("DELETE", `/setup-keys/${id}`); } @@ -220,6 +221,6 @@ export class NetbirdClient { // --------------------------------------------------------------------------- listEvents(): Promise { - return this.request("GET", "/events"); + return this.request("GET", "/events/audit"); } }