Skip to content

Commit

Permalink
feat(@vben/request): export basic HttpResponse generic (#4697)
Browse files Browse the repository at this point in the history
  • Loading branch information
gee1k authored Oct 21, 2024
1 parent 625862e commit 88d2b3e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { AxiosRequestConfig, AxiosResponse } from 'axios';
import type { AxiosRequestConfig } from 'axios';

import type { RequestClient } from '../request-client';
import type { RequestResponse } from '../types';

class FileDownloader {
private client: RequestClient;
Expand All @@ -12,13 +13,13 @@ class FileDownloader {
public async download(
url: string,
config?: AxiosRequestConfig,
): Promise<AxiosResponse<Blob>> {
): Promise<RequestResponse<Blob>> {
const finalConfig: AxiosRequestConfig = {
...config,
responseType: 'blob',
};

const response = await this.client.get<AxiosResponse<Blob>>(
const response = await this.client.get<RequestResponse<Blob>>(
url,
finalConfig,
);
Expand Down
3 changes: 3 additions & 0 deletions packages/effects/request/src/request-client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import type {
InternalAxiosRequestConfig,
} from 'axios';

type RequestResponse<T = any> = AxiosResponse<T>;

type RequestContentType =
| 'application/json;charset=utf-8'
| 'application/octet-stream;charset=utf-8'
Expand Down Expand Up @@ -46,5 +48,6 @@ export type {
RequestClientOptions,
RequestContentType,
RequestInterceptorConfig,
RequestResponse,
ResponseInterceptorConfig,
};

0 comments on commit 88d2b3e

Please sign in to comment.