(config: OpenAPIConfig, options: ApiRequestOptions)
| 291 | * @throws ApiError |
| 292 | */ |
| 293 | export const request = <T>(config: OpenAPIConfig, options: ApiRequestOptions): CancelablePromise<T> => { |
| 294 | return new CancelablePromise(async (resolve, reject, onCancel) => { |
| 295 | try { |
| 296 | const url = getUrl(config, options); |
| 297 | const formData = getFormData(options); |
| 298 | const body = getRequestBody(options); |
| 299 | const headers = await getHeaders(config, options); |
| 300 | |
| 301 | if (!onCancel.isCancelled) { |
| 302 | const response = await sendRequest(config, options, url, body, formData, headers, onCancel); |
| 303 | const responseBody = await getResponseBody(response); |
| 304 | const responseHeader = getResponseHeader(response, options.responseHeader); |
| 305 | |
| 306 | const result: ApiResult = { |
| 307 | url, |
| 308 | ok: response.ok, |
| 309 | status: response.status, |
| 310 | statusText: response.statusText, |
| 311 | body: responseHeader ?? responseBody, |
| 312 | }; |
| 313 | |
| 314 | catchErrorCodes(options, result); |
| 315 | |
| 316 | resolve(result.body); |
| 317 | } |
| 318 | } catch (error) { |
| 319 | reject(error); |
| 320 | } |
| 321 | }); |
| 322 | }; |
nothing calls this directly
no test coverage detected