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

pluginClient: fetch. Add header in response object. #1485

Open
nimo23 opened this issue Dec 23, 2024 · 0 comments
Open

pluginClient: fetch. Add header in response object. #1485

nimo23 opened this issue Dec 23, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@nimo23
Copy link

nimo23 commented Dec 23, 2024

What is the problem this feature would solve?

Currently, the (fetch) response generated by Kubb looks like this:

export const fetchClient = async <TData, TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {
  const response = await fetch([config.baseURL, config.url].filter(Boolean).join(''), {
    method: config.method.toUpperCase(),
    body: JSON.stringify(config.data),
    signal: config.signal,
    headers: config.headers,
  })

  const data = (await response.json()) as TData

  return {
    data,
    status: response.status,
    statusText: response.statusText,
  }
}

for

pluginClient({
..
client: 'fetch',
dataReturnType: 'full'
})

There is no header-response.

External documents/projects?

No response

What is the feature you are proposing to solve the problem?

Please add the header-response:

return {
    data,
    status: response.status,
    statusText: response.statusText,

    // Add headers into the response
    headers: response.headers
}

What alternatives have you considered?

No response

@nimo23 nimo23 added the enhancement New feature or request label Dec 23, 2024
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

No branches or pull requests

1 participant