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:
@@ -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',
|
||||
|
Reference in New Issue
Block a user