fix: request download and upload not support responseReturn (#5456)

* fix: request download and upload not support `responseReturn`

* docs: update

* fix: type of request client upload result
This commit is contained in:
Netfan
2025-01-22 00:59:10 +08:00
committed by GitHub
parent 195ceec9b4
commit e225159cce
7 changed files with 93 additions and 28 deletions

View File

@@ -1,6 +1,5 @@
import type { AxiosRequestConfig, AxiosResponse } from 'axios';
import type { RequestClient } from '../request-client';
import type { RequestClientConfig } from '../types';
class FileUploader {
private client: RequestClient;
@@ -9,18 +8,18 @@ class FileUploader {
this.client = client;
}
public async upload(
public async upload<T = any>(
url: string,
data: Record<string, any> & { file: Blob | File },
config?: AxiosRequestConfig,
): Promise<AxiosResponse> {
config?: RequestClientConfig,
): Promise<T> {
const formData = new FormData();
Object.entries(data).forEach(([key, value]) => {
formData.append(key, value);
});
const finalConfig: AxiosRequestConfig = {
const finalConfig: RequestClientConfig = {
...config,
headers: {
'Content-Type': 'multipart/form-data',