Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/api/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export interface ConfigOptions {
* in milliseconds.
*/
timeout?: number;
/**
* Additional arguments to pass to the `init` object used in fetch requests.
* These will be shallow-merged with internal options. The `signal` property is always managed internally and cannot be overridden.
*/
init?: Omit<RequestInit, 'signal'>;
}

export interface FetchResponse<status, data> {
Expand Down Expand Up @@ -109,7 +114,7 @@ export default class APICore {
const har = oasToHar(this.spec, operation, data, prepareAuth(this.auth, operation));

let timeoutSignal: any;
const init: RequestInit = {};
const init: RequestInit = { ...this.config.init };
if (this.config.timeout) {
const controller = new AbortController();
timeoutSignal = setTimeout(() => controller.abort(), this.config.timeout);
Expand Down