Constructor
new Requestable(authopt, apiBaseopt)
Initialize the http internals.
Initialize the http internals.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
auth |
Requestable.auth |
<optional> |
the credentials to authenticate to Xnat. If auth is not provided request will be made unauthenticated |
apiBase |
string |
<optional> |
the base Xnat URL |
- Source:
Methods
(protected) _getOptionsWithDefaults(requestOptionsopt) → {Object}
Sets the default options for API requests
.Sets the default options for API requests
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
requestOptions |
Object |
<optional> |
{} | the current options for the request |
- Source:
Returns:
- the options to pass to the request
- Type
- Object
(async) _request(method, path, bodyParamsopt, cbopt, rawopt) → {Promise}
Make a request.
Make a request.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
method |
string | the method for the request (GET, PUT, POST, DELETE) |
||
path |
string | the path for the request |
||
bodyParams |
* |
<optional> |
the data to send to the server. For HTTP methods that don't have a body the data will be sent as query parameters |
|
cb |
Requestable.callback |
<optional> |
the callback for the request |
|
raw |
boolean |
<optional> |
false | if the request should be sent as raw. If this is a falsy value then the request will be made as JSON |
- Source:
Returns:
- the Promise for the http request
- Type
- Promise
_request204or404(path, data, cb, methodopt) → {Promise}
Make a request to an endpoint the returns 204 when true and 404 when false
.Make a request to an endpoint the returns 204 when true and 404 when false
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
path |
string | the path to request |
||
data |
Object | any query parameters for the request |
||
cb |
Requestable.callback | the callback that will receive |
||
method |
method |
<optional> |
GET | HTTP Method to use |
- Source:
Returns:
- the promise for the http request
- Type
- Promise
Type Definitions
callback(error, result, request)
A function that receives the result of the API request.
A function that receives the result of the API request.
Parameters:
Name | Type | Description |
---|---|---|
error |
Requestable.Error | the error returned by the API or |
result |
Object | true | the data returned by the API or |
request |
Object | the raw Response |
- Source: