We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
fetch
headers: true
client: "fetch"
orval.config.ts
orval
The headers are not passed to fetch.
This is an example of generated code:
export const getUser = async ( headers: GetUserHeaders, options?: RequestInit ): Promise<User> => { const res = await fetch(getGetUserUrl(), { ...options, method: "GET", }); const data = await res.json(); return data as User; };
The headers should be passed to fetch:
export const getUser = async ( headers: GetUserHeaders, options?: RequestInit ): Promise<User> => { const res = await fetch(getGetUserUrl(), { ...options, + headers: { ...headers, ...options?.headers }, method: "GET", }); const data = await res.json(); return data as User; };
With axios it works as expected:
axios
export const getUser = <TData = AxiosResponse<User>>( headers: GetUserHeaders, options?: AxiosRequestConfig ): Promise<TData> => { return axios.get(`http://127.0.0.1:3999/user`, { ...options, headers: { ...headers, ...options?.headers }, }); };
orval: 7.3.0 react: 19.0.0
The text was updated successfully, but these errors were encountered:
PR is welcome!
Sorry, something went wrong.
fix(fetch): pass headers to fetch when headers option is activated (
headers
48bfb70
orval-labs#1779)
9784454
#1780) * fix(fetch): pass headers to `fetch` when `headers` option is activated (#1779) * test(fetch): add test for `headers` config parameter
clemeth
Successfully merging a pull request may close this issue.
What are the steps to reproduce this issue?
headers: true
andclient: "fetch"
inorval.config.ts
.orval
.What happens?
The headers are not passed to
fetch
.This is an example of generated code:
What were you expecting to happen?
The headers should be passed to
fetch
:export const getUser = async ( headers: GetUserHeaders, options?: RequestInit ): Promise<User> => { const res = await fetch(getGetUserUrl(), { ...options, + headers: { ...headers, ...options?.headers }, method: "GET", }); const data = await res.json(); return data as User; };
With
axios
it works as expected:What versions are you using?
The text was updated successfully, but these errors were encountered: