Specifies the expected response type for automatic parsing.
'text'
Response.text()
'json'
Response.json()
'arraybuffer'
Response.arrayBuffer()
'bytes'
Response.bytes()
'blob'
Response.blob()
'stream'
ReadableStream
If not specified, the raw Response object is returned.
Response
import { fetchT, type FetchResponseType } from '@happy-ts/fetch-t';const responseType: FetchResponseType = 'json';const result = await fetchT('https://api.example.com/data', { responseType }); Copy
import { fetchT, type FetchResponseType } from '@happy-ts/fetch-t';const responseType: FetchResponseType = 'json';const result = await fetchT('https://api.example.com/data', { responseType });
Specifies the expected response type for automatic parsing.
'text'- Parse response as string viaResponse.text()'json'- Parse response as JSON viaResponse.json()'arraybuffer'- Parse response as ArrayBuffer viaResponse.arrayBuffer()'bytes'- Parse response as Uint8ArrayResponse.bytes()(with fallback for older environments)'blob'- Parse response as Blob viaResponse.blob()'stream'- Return the rawReadableStreamfor streaming processingIf not specified, the raw
Responseobject is returned.