Skip to content

openapi-fetch: How to specify which content-type is returned in data? #1866

Discussion options

You must be logged in to vote

Update. Eventually figured out that you also can pass a second type arg to createClient. Like so:

export const client = createClient<paths, 'application/json'>({
  baseUrl: '...',
  headers: {
    'Content-Type': 'application/json',
  },
})

Now the second question is if there a way to change this per request basis or if I need to create separate clients for each response type?

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ViktorPontinen
Comment options

Answer selected by ViktorPontinen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
enhancement New feature or request openapi-fetch Relevant to the openapi-fetch library
1 participant