Configuration
The configuration options available for HttxClient.
HttxConfig
interface HttxConfig {
verbose?: boolean | string[]
defaultHeaders?: Record<string, string>
baseUrl?: string
timeout?: number
}Properties
verbose
verbose?: boolean | string[]Enable debug logging for the client.
boolean: Enable/disable all debug loggingstring[]: Enable debug logging for specific categories
Example:
const client = new HttxClient({
verbose: ['request', 'response'] // Only log request and response details
})defaultHeaders
defaultHeaders?: Record<string, string>Default headers to include in all requests.
Example:
const client = new HttxClient({
defaultHeaders: {
'Authorization': 'Bearer token123',
'X-API-Key': 'your-api-key'
}
})baseUrl
baseUrl?: stringBase URL for all requests. Will be prepended to all request URLs unless the URL is absolute.
Example:
const client = new HttxClient({
baseUrl: 'https://api.example.com/v1'
})
// Request will go to https://api.example.com/v1/users
await client.request('/users', { method: 'GET' })timeout
timeout?: numberDefault timeout in milliseconds for all requests. Can be overridden per request.
Example:
const client = new HttxClient({
timeout: 5000 // 5 seconds
})RequestOptions
interface RequestOptions {
method: HttpMethod
headers?: Record<string, string>
body?: BodyInit | Record<string, string>
query?: Record<string, string>
timeout?: number
json?: boolean
form?: boolean
multipart?: boolean
verbose?: boolean
}Properties
method
method: HttpMethodHTTP method to use for the request.
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS'headers
headers?: Record<string, string>Request-specific headers. Will be merged with default headers.
body
body?: BodyInit | Record<string, string>Request body. Can be:
BodyInit: Raw body dataRecord<string, string>: Object to be converted to form data or JSON
query
query?: Record<string, string>Query parameters to append to the URL.
timeout
timeout?: numberRequest-specific timeout in milliseconds. Overrides the default timeout.
json
json?: booleanWhether to send/receive JSON data. Sets appropriate Content-Type and Accept headers.
form
form?: booleanWhether to send form data. Sets appropriate Content-Type header.
multipart
multipart?: booleanWhether to send multipart form data. Sets appropriate Content-Type header.
verbose
verbose?: booleanEnable debug logging for this specific request.