Class

HttpClient

HttpClient(options)

Fetch wrapper that handles API key headers, auth tokens, timeouts, and error mapping. Zero dependencies - uses native fetch and AbortController.

Constructor

# new HttpClient(options)

Parameters:
Name Type Attributes Default Description
options object
baseUrl string

Full base URL (host + basePath), e.g. 'https://api.example.com/identity/auth'

apiKey string

Hiyve public API key

timeout number <optional>
30000

Request timeout in ms

getAccessToken function <optional>

Returns current access token or null

Classes

HttpClient

Methods

# _mapHttpError(status, data) → {AuthError}

Map HTTP status codes to AuthError instances.

Parameters:
Name Type Description
status number
data object | null

Parsed response body

AuthError

# async delete()

DELETE request helper.

# async get()

GET request helper.

# async post()

POST request helper.

# async put()

PUT request helper.

# async request(method, path, bodyopt, optionsopt) → {Promise.<object>}

Make an HTTP request.

Parameters:
Name Type Attributes Default Description
method string

HTTP method

path string

Path appended to baseUrl (e.g. '/login')

body object <optional>
null

JSON request body

options object <optional>
auth boolean <optional>
false

Include Authorization header

timeout number <optional>

Override default timeout

Parsed JSON response

Promise.<object>