@@ -93,11 +93,23 @@ axiosInstance.interceptors.response.use(
9393 } ,
9494) ;
9595
96+ export async function commonRequest (
97+ rawUrl : string ,
98+ params : Partial < AxiosRequestConfig > ,
99+ options : Partial < ICommonRequestOptions > & { responseType : 'empty' } ,
100+ ) : Promise < void > ;
101+ export async function commonRequest < T > (
102+ rawUrl : string ,
103+ params ?: Partial < AxiosRequestConfig > ,
104+ options ?: Partial < ICommonRequestOptions > ,
105+ ) : Promise < T > ;
106+
107+ /* eslint-disable consistent-return */
96108export async function commonRequest < T > (
97109 rawUrl : string ,
98110 params : Partial < AxiosRequestConfig > = { } ,
99111 options : Partial < ICommonRequestOptions > = { } ,
100- ) : Promise < T > {
112+ ) : Promise < T | void > {
101113 const {
102114 api : { publicUrl, urls } ,
103115 } = getBrowserConfigEnv ( ) ;
@@ -114,14 +126,14 @@ export async function commonRequest<T>(
114126 const config : AxiosRequestConfig = {
115127 ...params ,
116128 timeout : timeOut ,
117- responseType : options . responseType === 'text' ? 'text' : 'json' ,
129+ responseType : options . responseType === 'text' || options . responseType === 'empty' ? 'text' : 'json' ,
118130 validateStatus : ( status ) => successStatusCodes . includes ( status ) ,
119131 } ;
120132
121133 const response = await axiosInstance ( fullUrl , config ) ;
122134
123- if ( options . responseType === 'text ' ) {
124- return response . data as T ;
135+ if ( options . responseType === 'empty ' ) {
136+ return ;
125137 }
126138
127139 return response . data as T ;
@@ -130,6 +142,7 @@ export async function commonRequest<T>(
130142 throw error ;
131143 }
132144 logger . error ( error ) ;
133- return undefined as unknown as T ;
145+
134146 }
135147}
148+ /* eslint-enable consistent-return */
0 commit comments