Skip to content

Support usage of URLSearchParams as a value for query / params #322

@noook

Description

@noook

Describe the feature

I naively used URLSearchParams in order to prepare the parameters I want to send along the request, however those are not read if I use an interceptor later on.

const $fetch = ofetch.create({
  baseURL: this.baseUrl,
  onRequest: ({ options }) => {
    options.query ||= new URLSearchParams();
    options.query.set('token', this.token);
  }
});

const query = new URLSearchParams({
  title,
});

$fetch(url, { query })

Is it something unwanted, or is a contribution welcome for this one ?

Additional information

  • Would you be willing to help implement this feature?

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