unjs / unjs/ofetch

Set params in onRequest

Open
#477 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.4k
Forks
195
PR merge metrics
No merged PRs in 30d

Description

Environment

ofetch@1.4.1

Reproduction
const _customFetch = $fetch.create({});
    const { path } = await _customFetch(getURL("echo"), {
      onRequest(ctx) {
        ctx.options.params = {
          d: 4,
        }
      }
    });
Describe the bug

When set params in onRequest.

The context.request is not withQuery.

Additional context

No response

Logs

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproduction using ofetch@1.4.1 and trace the onRequest callback where ctx.options.params is assigned. Verify how the request URL is built, then confirm the fix by checking that the d=4 parameter appears in the resulting request when params are set inside onRequest.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.