mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 08:46:22 +02:00
add documents api service
This commit is contained in:
parent
6378d27bcb
commit
5a887e9243
3 changed files with 284 additions and 1 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue