new httpUtils(backendUrl, appIdopt, appSecretopt)
Utility class with wrappers for calling authenticated API endpoints.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
backendUrl |
String | The base backend URL | |
appId |
String |
<optional> |
Application ID, without this only unauthorized APIs can be used |
appSecret |
String |
<optional> |
Application shared secret, without this only unauthorized APIs can be used |
- Source:
Methods
buildUrl(path, paramsopt) → {string}
Build a URL with optional query string
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
string | the endpoint to build | |
params |
* |
<optional> |
optional parameters to add to the query string |
- Source:
Returns:
the absolute URL
- Type
- string
delete(path, paramsopt) → {Promise.<*>}
Authenticated DELETE request
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
string | the endpoint to build | |
params |
* |
<optional> |
optional parameters to add to the query string |
- Source:
Returns:
resolves to the API result
- Type
- Promise.<*>
get(path, paramsopt) → {Promise.<*>}
Authenticated GET request
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
string | the endpoint to build | |
params |
* |
<optional> |
optional parameters to add to the query string |
- Source:
Returns:
resolves to the API result
- Type
- Promise.<*>
getHeaders(absoluteUrl, bodyopt) → {object}
Get the headers for the request
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
absoluteUrl |
string | the absolute URL for the request | |
body |
string |
<optional> |
optional HTTP body |
- Source:
Returns:
Object with headers for the request; empty object if no auth is needed
- Type
- object
post(path, paramsopt, jsonBodyopt) → {Promise.<*>}
Authenticated POST request
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
string | the endpoint to build | |
params |
* |
<optional> |
optional parameters to add to the query string |
jsonBody |
* |
<optional> |
optional body |
- Source:
Returns:
resolves to the API result
- Type
- Promise.<*>