Constructor
(package) new DataRequest()
Instantiates a new DataRequest
, defining the Content-Type
in the
headers
and setting the
version
, if required.
Members
(package, nullable) version :number
Defines the version of the NS API to request all data in. If null
,
requests are made to the most recent version of the API automatically.
Type:
- number
Methods
getArgument(key) → {string}
Get the value that is currently saved in this request's
body
under the given key.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | Name of the argument |
Returns:
Data currently saved for that argument
- Type
- string
getArguments() → {Array.<string>}
Get the keys of all values that are currently set in the request
body
.
Returns:
List of all keys currently set
- Type
- Array.<string>
(protected) mandate(…names) → {this}
Registers the given parameter names as required to have a value set for
them in the data
before executing the request.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
names |
string |
<repeatable> |
Names of the URL parameters to mandate |
Returns:
The request, for chaining
- Type
- this
(async) raw()
removeArgument(key) → {this}
Remove the value saved under the given key in the request
body
.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | Name of the key |
Returns:
The request, for chaining
- Type
- this
setArgument(key, …values) → {this}
Set the given value under the given argument name in the request
body
.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
key |
string | Key to save the value under |
|
values |
Array.<any> |
<repeatable> |
Value(s) to save; joined with |
Returns:
The request, for chaining
- Type
- this
setArguments(pairs, replace) → {this}
Set all the given keys and values in the request
body
.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
pairs |
Object.<string, string> | Key-value pairs of arguments |
|
replace |
boolean | false |
|
Returns:
The request, for chaining
- Type
- this