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

fix(fetch): fetch client can now override headers with options #1627

Merged

Conversation

soartec-lab
Copy link
Member

Status

READY

Description

fix #1622

The fetch client could not override header with options, so i fixed it.

Before

The fetch client could not override headers with options because headers implement after ...options so headers is always fixed.

return customFetch<Promise<createPetsResponse>>(getCreatePetsUrl(), {
  ...options,
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify(createPetsBodyItem),
});

After

headers implement contains ...options?.headers

return customFetch<Promise<createPetsResponse>>(getCreatePetsUrl(), {
  ...options,
  method: 'POST',
  headers: { 'Content-Type': 'application/json', ...options?.headers },
  body: JSON.stringify(createPetsBodyItem),
});

Related PRs

none

Todos

  • Tests
  • Documentation
  • Changelog Entry (unreleased)

Steps to Test or Reproduce

You can check by using sample app.

@soartec-lab soartec-lab added bug Something isn't working fetch Fetch client related issue labels Sep 15, 2024
@melloware melloware merged commit d9fcfd5 into orval-labs:master Sep 15, 2024
2 checks passed
@melloware melloware added this to the 7.1.1 milestone Sep 15, 2024
@sharenz
Copy link

sharenz commented Sep 16, 2024

oh nice, thanks for fixing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fetch Fetch client related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FETCH: Custom headers provided in options are overwritten for POST
3 participants