Skip to content

Allow passing options to fetch #1046

@Magi1053

Description

@Magi1053

Looks like this should be simple to implement and absolutely required for my use case, as I need to be able to pass an agent property to the fetch options but it seems like this is not currently allowed. Looking at the code all I need is to be able to add custom values to the init (type RequestInit) property (possibly through a core.config entry) and it should pass through.

const init: RequestInit = {};
if (this.config.timeout) {
const controller = new AbortController();
timeoutSignal = setTimeout(() => controller.abort(), this.config.timeout);
init.signal = controller.signal;
}
// `getHarForRequest` returns a partial HAR object, by way of `@readme/oas-to-har` but
// `fetch-har` is typed to expect the full thing. Though we're supplying an incomplete HAR
// object, at least the spec, our partial is fine.
return fetchHar(har as unknown as Har, { files: data.files || {}, init, userAgent: this.userAgent })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions