Skip to main content

HttpResponse<T>

The response envelope returned by all client methods.

interface HttpResponse<T> {
data: T
status: number
statusText: string
headers: Headers
config: RequestConfig
}

Fields

FieldTypeDescription
dataTThe parsed response body. Type depends on responseType and any validate function.
statusnumberHTTP status code (e.g., 200, 201, 204).
statusTextstringHTTP status text (e.g., 'OK', 'Created').
headersHeadersResponse headers as a native Headers object.
configRequestConfigThe merged request config, with sensitive header values redacted.

Data type by responseType

responseTypedata type
'json' (default)Parsed JSON (typed as T)
'text'string
'arraybuffer'ArrayBuffer
'blob'Blob
'stream'ReadableStream<Uint8Array> | null — the un-consumed body stream. Validation is skipped for this mode.

Example

import { createClient } from '@parcely/core'

const http = createClient({ baseURL: 'https://api.example.com' })

const response = await http.get<{ id: string; name: string }>('/users/me')

console.log(response.data) // { id: '1', name: 'Mickey' }
console.log(response.status) // 200
console.log(response.statusText) // 'OK'
console.log(response.headers.get('content-type')) // 'application/json'
console.log(response.config.url) // '/users/me'

Config redaction

The config field has sensitive header values replaced with '[REDACTED]'. This is safe to log. Request interceptors see the live un-redacted config.

See also