Methods
createUniqueID(prefixopt) → {string}
- Source:
- Since:
- 0.0.1
Generates a unique ID to prevent ID name clashes. This function
will never generate the same ID twice during the existence of a
specific instance of the Requester class.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
prefix |
string |
<optional> |
''
|
String which will be applied as the first part of every generated unique ID. |
Returns:
The generated ID. Returned IDs have the
format "${prefix}#${serial number}#${timestamp}", where prefix is
a string prefix optionally provided by the user.
- Type
- string
(async) delete(url, id, …params)
- Source:
- Since:
- 0.0.3
Perform an HTTP DELETE request and cache response
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
url |
string | URL of request | |
id |
string | Unique ID of request, used to retrieve results | |
params |
string |
<repeatable> |
Parameters of request. Each request parameter should use two function parameters, the first the name of the parameter and the second it's value. The number of arguments in params should always be even. |
error(id) → {Object}
- Source:
- Since:
- 0.0.1
Retrieve an error based on it's ID
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The ID passed into the HTTP request when it was created |
Throws:
-
-
Thrown when a response is requested from an in-flight request.
- Type
- RequestNotCompleteError
-
-
-
Thrown when an ID does not exist. Caused by a request never having been made or already having been retrieved. Retrieved requests are deleted from the cache to prevent a memory leak on long running apps.
- Type
- InvalidRequestError
-
Returns:
The error returned. Will be set to undefined
if the request succeeded.
- Type
- Object
(async) get(url, id, …params)
- Source:
- Since:
- 0.0.1
Perform an HTTP GET request and cache response
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
url |
string | URL of request | |
id |
string | Unique ID of request, used to retrieve results | |
params |
string |
<repeatable> |
Parameters of request. Each request parameter should use two function parameters, the first the name of the parameter and the second it's value. The number of arguments in params should always be even. |
(async) patch(url, id, data, …params)
- Source:
- Since:
- 0.0.3
Perform an HTTP PATCH request and cache response
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
url |
string | URL of request | |
id |
string | Unique ID of request, used to retrieve results | |
data |
Object | Data for request. | |
params |
string |
<repeatable> |
Parameters of request. Each request parameter should use two function parameters, the first the name of the parameter and the second it's value. The number of arguments in params should always be even. |
(async) post(url, id, data, …params)
- Source:
- Since:
- 0.0.3
Perform an HTTP POST request and cache response
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
url |
string | URL of request | |
id |
string | Unique ID of request, used to retrieve results | |
data |
Object | Data for request. | |
params |
string |
<repeatable> |
Parameters of request. Each request parameter should use two function parameters, the first the name of the parameter and the second it's value. The number of arguments in params should always be even. |
(async) push(url, id, data, …params)
- Source:
- Since:
- 0.0.3
Perform an HTTP PUSH request and cache response
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
url |
string | URL of request | |
id |
string | Unique ID of request, used to retrieve results | |
data |
Object | Data for request. | |
params |
string |
<repeatable> |
Parameters of request. Each request parameter should use two function parameters, the first the name of the parameter and the second it's value. The number of arguments in params should always be even. |
response(id) → {Object}
- Source:
- Since:
- 0.0.0
Retrieve a response based on it's ID
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The ID passed into the HTTP request when it was created |
Throws:
-
-
Thrown when a response is requested from an in-flight request.
- Type
- RequestNotCompleteError
-
-
-
Thrown when an ID does not exist. Caused by a request never having been made or already having been retrieved. Retrieved requests are deleted from the cache to prevent a memory leak on long running apps.
- Type
- InvalidRequestError
-
Returns:
The response returned. Will be set to undefined
if the request failed.
- Type
- Object
setOptions(options) → {Object}
- Source:
- Since:
- 0.0.3
Set new options, or restore to defaults.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | Options passed in to function. Options not set in options will be left at current value. If options is an empty object, reset all options to defaults. If options is null, return a copy of the current options. |
Returns:
Copy of options after any changes.
- Type
- Object