Skip to content

Commit 7fd4fab

Browse files
committed
generic type for response
1 parent d04a7be commit 7fd4fab

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

http/index.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,15 @@ async function getRequest<T>(
123123
accountId: number,
124124
options: HttpOptions,
125125
withFullResponse = false
126-
): Promise<T | AxiosResponse> {
126+
): Promise<T> {
127127
const { params, ...rest } = options;
128128
const axiosConfig = addQueryParams(rest, params);
129129
const configWithAuth = await withAuth(accountId, axiosConfig);
130130

131131
const response = await axios<T>(configWithAuth);
132132

133133
if (withFullResponse) {
134-
return response;
134+
return response as T;
135135
}
136136

137137
return response.data;
@@ -141,13 +141,13 @@ async function postRequest<T>(
141141
accountId: number,
142142
options: HttpOptions,
143143
withFullResponse = false
144-
): Promise<T | AxiosResponse> {
144+
): Promise<T> {
145145
const configWithAuth = await withAuth(accountId, options);
146146

147147
const response = await axios({ ...configWithAuth, method: 'post' });
148148

149149
if (withFullResponse) {
150-
return response;
150+
return response as T;
151151
}
152152

153153
return response.data;
@@ -157,12 +157,12 @@ async function putRequest<T>(
157157
accountId: number,
158158
options: HttpOptions,
159159
withFullResponse = false
160-
): Promise<T | AxiosResponse> {
160+
): Promise<T> {
161161
const configWithAuth = await withAuth(accountId, options);
162162
const response = await axios({ ...configWithAuth, method: 'put' });
163163

164164
if (withFullResponse) {
165-
return response;
165+
return response as T;
166166
}
167167

168168
return response.data;
@@ -172,12 +172,12 @@ async function patchRequest<T>(
172172
accountId: number,
173173
options: HttpOptions,
174174
withFullResponse = false
175-
): Promise<T | AxiosResponse> {
175+
): Promise<T> {
176176
const configWithAuth = await withAuth(accountId, options);
177177
const response = await axios({ ...configWithAuth, method: 'patch' });
178178

179179
if (withFullResponse) {
180-
return response;
180+
return response as T;
181181
}
182182

183183
return response.data;
@@ -187,12 +187,12 @@ async function deleteRequest<T>(
187187
accountId: number,
188188
options: HttpOptions,
189189
withFullResponse = false
190-
): Promise<T | AxiosResponse> {
190+
): Promise<T> {
191191
const configWithAuth = await withAuth(accountId, options);
192192
const response = await axios({ ...configWithAuth, method: 'delete' });
193193

194194
if (withFullResponse) {
195-
return response;
195+
return response as T;
196196
}
197197

198198
return response.data;

0 commit comments

Comments
 (0)