Skip to content

Allow passing options to fetch #1046

Open

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 })

Activity

  1. Magi1053 commented on Jun 28, 2025

    @Magi1053
    Author

    Image

  2. erunion commented on Jun 30, 2025

    @erunion
    Member

    If you would like to submit a PR for this we'll accept it!

  3. bombillazo commented on Aug 15, 2025

    @bombillazo

    Similar to this, is there currently any way to pass or set interceptors to the fetch client?

  4. erunion commented on Aug 15, 2025

    @erunion
    Member

    @bombillazo Unfortunately not right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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