openapi-typescript-fetch icon indicating copy to clipboard operation
openapi-typescript-fetch copied to clipboard

Allow responses other that json (or plain text)

Open doktordirk opened this issue 3 years ago • 1 comments

Atm, other formats are not allowed. To be backwards compatible, one option could be to always also return the original response

async function getResponseData(response: Response) {
// ...
const text = await response.clone().text()
//...
}
async function fetchJson(url: string, init: RequestInit): Promise<ApiResponse> {
//...
 const result = {
	...response,
    data,
  }
//...
}

doktordirk avatar Jan 02 '22 17:01 doktordirk

It really should not throw if the spec defines the response as plain/text and the status is 200. What is a good work-around for that?

vdawg-git avatar Jun 12 '23 12:06 vdawg-git