1
1
{{> header }}
2
2
3
3
import axios from 'axios';
4
- import type { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';
4
+ import type { AxiosError, AxiosRequestConfig, AxiosResponse, AxiosInstance } from 'axios';
5
5
import FormData from 'form-data';
6
6
7
7
import { ApiError } from './ApiError';
@@ -66,10 +66,11 @@ import type { OpenAPIConfig } from './OpenAPI';
66
66
* Request method
67
67
* @param config The OpenAPI configuration object
68
68
* @param options The request options from the service
69
+ * @param axiosClient The axios client instance to use
69
70
* @returns CancelablePromise<T >
70
71
* @throws ApiError
71
72
*/
72
- export const request = <T >(config: OpenAPIConfig, options: ApiRequestOptions): CancelablePromise<T > => {
73
+ export const request = <T >(config: OpenAPIConfig, options: ApiRequestOptions, axiosClient: AxiosInstance = axios ): CancelablePromise<T > => {
73
74
return new CancelablePromise(async (resolve, reject, onCancel) => {
74
75
try {
75
76
const url = getUrl(config, options);
@@ -78,7 +79,7 @@ export const request = <T>(config: OpenAPIConfig, options: ApiRequestOptions): C
78
79
const headers = await getHeaders(config, options, formData);
79
80
80
81
if (!onCancel.isCancelled) {
81
- const response = await sendRequest<T >(config, options, url, body, formData, headers, onCancel);
82
+ const response = await sendRequest<T >(config, options, url, body, formData, headers, onCancel, axiosClient );
82
83
const responseBody = getResponseBody(response);
83
84
const responseHeader = getResponseHeader(response, options.responseHeader);
84
85
0 commit comments