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
Methods
# _mapHttpError(status, data) → {AuthError}
Map HTTP status codes to AuthError instances.
Parameters:
| Name | Type | Description |
|---|---|---|
status |
number
|
|
data |
object
|
null
|
Parsed response body |
# 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>