Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fetch): support custom mutator #1457

Merged

Conversation

soartec-lab
Copy link
Member

Status

READY

Description

follow up #1387
I made fetch client available to custom mutators.
when we config to orverride.mutator, fetch client passes url and params to custom fetch function.

default

export const listPets = async (
  params?: ListPetsParams,
  options?: RequestInit,
): Promise<Pets> => {
  const res = await fetch(getUpdatePetsUrl(), {
    ...options,
    method: 'GET',
  });

  return res.json();
};

use orverride.mutator

export const listPets = async (
  params?: ListPetsParams,
  options?: RequestInit,
): Promise<Pets> => {
  return customFetch<Promise<Pets>>(getListPetsUrl(params), {
    ...options,
    method: 'GET',
  });
};

Related PRs

none

Todos

  • Tests
  • Documentation
  • Changelog Entry (unreleased)

Steps to Test or Reproduce

The sample app using custom mutator, so you can run and check it

cd samples/next-app-with-fetch/
yarn dev

@soartec-lab soartec-lab added this to the 6.31.0 milestone Jun 16, 2024
@soartec-lab soartec-lab added the enhancement New feature or request label Jun 16, 2024
@soartec-lab soartec-lab linked an issue Jun 16, 2024 that may be closed by this pull request
7 tasks
@soartec-lab soartec-lab merged commit 95a2932 into orval-labs:master Jun 17, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support fetch client
2 participants