fix: use fetch for DELETE+body to fix file_delete (#649) #20
+15
-1
@@ -52,7 +52,21 @@ export class GiteaClient {
|
||||
}
|
||||
|
||||
async delete(endpoint: string, body?: unknown): Promise<ApiResponse> {
|
||||
return this.request(this.buildUrl(endpoint), 'DELETE', body);
|
||||
if (body === undefined) {
|
||||
return this.request(this.buildUrl(endpoint), 'DELETE');
|
||||
}
|
||||
// Use fetch for DELETE+body — node:https drops the body on some
|
||||
// proxy/TLS configurations, causing the server to see an empty request.
|
||||
const url = this.buildUrl(endpoint);
|
||||
const resp = await fetch(url, {
|
||||
method: 'DELETE',
|
||||
headers: { ...this.headers },
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
const raw = await resp.text();
|
||||
let data: unknown;
|
||||
try { data = JSON.parse(raw); } catch { data = raw; }
|
||||
return { status: resp.status, data };
|
||||
}
|
||||
|
||||
private buildUrl(endpoint: string, params?: Record<string, string>): string {
|
||||
|
||||
Reference in New Issue
Block a user