( config: OpenAPIConfig, options: ApiRequestOptions, )
| 307 | * @throws ApiError |
| 308 | */ |
| 309 | export const request = <T>( |
| 310 | config: OpenAPIConfig, |
| 311 | options: ApiRequestOptions, |
| 312 | ): CancelablePromise<T> => { |
| 313 | return new CancelablePromise(async (resolve, reject, onCancel) => { |
| 314 | try { |
| 315 | const url = getUrl(config, options); |
| 316 | const formData = getFormData(options); |
| 317 | const body = getRequestBody(options); |
| 318 | const headers = await getHeaders(config, options); |
| 319 | |
| 320 | if (!onCancel.isCancelled) { |
| 321 | const response = await sendRequest(config, options, url, body, formData, headers, onCancel); |
| 322 | const responseBody = await getResponseBody(response); |
| 323 | const responseHeader = getResponseHeader(response, options.responseHeader); |
| 324 | |
| 325 | const result: ApiResult = { |
| 326 | url, |
| 327 | ok: response.ok, |
| 328 | status: response.status, |
| 329 | statusText: response.statusText, |
| 330 | body: responseHeader ?? responseBody, |
| 331 | }; |
| 332 | |
| 333 | catchErrorCodes(options, result); |
| 334 | |
| 335 | resolve(result.body); |
| 336 | } |
| 337 | } catch (error) { |
| 338 | reject(error); |
| 339 | } |
| 340 | }); |
| 341 | }; |
nothing calls this directly
no test coverage detected