add documents api service

This commit is contained in:
thierryverse 2025-11-20 11:00:42 +02:00 committed by CREDO23
parent 6378d27bcb
commit 5a887e9243
3 changed files with 284 additions and 1 deletions

View file

@ -260,6 +260,26 @@ class BaseApiService {
responseType: ResponseType.BLOB,
});
}
async postFormData<T>(
url: string,
responseSchema?: z.ZodSchema<T>,
options?: Omit<RequestOptions, "method" | "responseType" | "body"> & { body: FormData }
) {
// Remove Content-Type from options headers if present
const { "Content-Type": _, ...headersWithoutContentType } = options?.headers ?? {};
return this.request(url, responseSchema, {
method: "POST",
...options,
headers: {
// Don't set Content-Type - let browser set it with multipart boundary
Authorization: `Bearer ${this.bearerToken}`,
...headersWithoutContentType,
},
responseType: ResponseType.JSON,
});
}
}
export const baseApiService = new BaseApiService(