mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
# Conflicts: # README.md # package.json # src/utils/registerHandlebarTemplates.ts # test/__snapshots__/index.spec.js.snap # test/custom/request.ts # test/e2e/v3.fetch.spec.js # test/e2e/v3.node.spec.js # yarn.lock
35 lines
992 B
TypeScript
35 lines
992 B
TypeScript
/* istanbul ignore file */
|
|
/* tslint:disable */
|
|
/* eslint-disable */
|
|
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
import { CancelablePromise } from './CancelablePromise';
|
|
import { OpenAPI } from './OpenAPI';
|
|
|
|
export function request<T>(options: ApiRequestOptions): CancelablePromise<T> {
|
|
return new CancelablePromise((resolve, reject, onCancel) => {
|
|
const url = `${OpenAPI.BASE}${options.path}`;
|
|
|
|
try {
|
|
// Do your request...
|
|
const timeout = setTimeout(() => {
|
|
resolve({
|
|
url,
|
|
ok: true,
|
|
status: 200,
|
|
statusText: 'dummy',
|
|
body: {
|
|
...options,
|
|
},
|
|
});
|
|
}, 500);
|
|
|
|
// Cancel your request...
|
|
onCancel(() => {
|
|
clearTimeout(timeout);
|
|
});
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
});
|
|
}
|