From 88d2b3e5696efea9d9b2b7c7422575b9ea4da1cd Mon Sep 17 00:00:00 2001 From: Svend Date: Mon, 21 Oct 2024 17:20:58 +0800 Subject: [PATCH] feat(@vben/request): export basic HttpResponse generic (#4697) --- .../request/src/request-client/modules/downloader.ts | 7 ++++--- packages/effects/request/src/request-client/types.ts | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/effects/request/src/request-client/modules/downloader.ts b/packages/effects/request/src/request-client/modules/downloader.ts index 947de0b32..bf065d335 100644 --- a/packages/effects/request/src/request-client/modules/downloader.ts +++ b/packages/effects/request/src/request-client/modules/downloader.ts @@ -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; @@ -12,13 +13,13 @@ class FileDownloader { public async download( url: string, config?: AxiosRequestConfig, - ): Promise> { + ): Promise> { const finalConfig: AxiosRequestConfig = { ...config, responseType: 'blob', }; - const response = await this.client.get>( + const response = await this.client.get>( url, finalConfig, ); diff --git a/packages/effects/request/src/request-client/types.ts b/packages/effects/request/src/request-client/types.ts index 44f647618..b85dded44 100644 --- a/packages/effects/request/src/request-client/types.ts +++ b/packages/effects/request/src/request-client/types.ts @@ -4,6 +4,8 @@ import type { InternalAxiosRequestConfig, } from 'axios'; +type RequestResponse = AxiosResponse; + type RequestContentType = | 'application/json;charset=utf-8' | 'application/octet-stream;charset=utf-8' @@ -46,5 +48,6 @@ export type { RequestClientOptions, RequestContentType, RequestInterceptorConfig, + RequestResponse, ResponseInterceptorConfig, };