( config: OpenAPIConfig, options: ApiRequestOptions<T>, url: string, body: unknown, formData: FormData | undefined, headers: Record<string, string>, onCancel: OnCancel, axiosClient: AxiosInstance, )
| 185 | } |
| 186 | |
| 187 | export const sendRequest = async <T>( |
| 188 | config: OpenAPIConfig, |
| 189 | options: ApiRequestOptions<T>, |
| 190 | url: string, |
| 191 | body: unknown, |
| 192 | formData: FormData | undefined, |
| 193 | headers: Record<string, string>, |
| 194 | onCancel: OnCancel, |
| 195 | axiosClient: AxiosInstance, |
| 196 | ): Promise<AxiosResponse<T>> => { |
| 197 | const controller = new AbortController() |
| 198 | |
| 199 | let requestConfig: AxiosRequestConfig = { |
| 200 | data: body ?? formData, |
| 201 | headers, |
| 202 | method: options.method, |
| 203 | signal: controller.signal, |
| 204 | url, |
| 205 | withCredentials: config.WITH_CREDENTIALS, |
| 206 | } |
| 207 | |
| 208 | onCancel(() => controller.abort()) |
| 209 | |
| 210 | for (const fn of config.interceptors.request._fns) { |
| 211 | requestConfig = await fn(requestConfig) |
| 212 | } |
| 213 | |
| 214 | try { |
| 215 | return await axiosClient.request(requestConfig) |
| 216 | } catch (error) { |
| 217 | const axiosError = error as AxiosError<T> |
| 218 | if (axiosError.response) { |
| 219 | return axiosError.response |
| 220 | } |
| 221 | throw error |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | export const getResponseHeader = ( |
| 226 | response: AxiosResponse<unknown>, |
nothing calls this directly
no outgoing calls
no test coverage detected