Request
Summary
Creates a REST request which can be executed / aborted.
Constructor
Request
Syntax
Request
-
protocol
-
[options]
-
[body]
-
[timeout=10000]
-
[multiparted=false]
Summary
Parameters:
-
protocol
StringThe protocol to use for the request (either 'http' or 'https')
-
[options]
Object optionalThe complete list of http(s) options as described by NodeJS http.request documentation. More headers can be added when executing the request.
-
[body]
String | Object optionalThe request body
-
[timeout=10000]
Number optionalMaximum execution time for the request (in ms), set it to Infinity for a request without limits
-
[multiparted=false]
Boolean optionaltrue to send body as multipart/form-data
Item Index
Methods
abort
Syntax
Summary
Aborts the request.
Returns:
Promise resolving when request has been aborted, promise is rejected if it takes too long to abort the request
execute
Syntax
Summary
Executes the request.
Be careful, if request is executed while still running, the running one will be aborted.
Parameters:
-
[headers]
Object optionalA list of http(s) headers. Headers will be merged with Request headers set in the constructor
Returns:
Promise resolving with request's response as an Object, all request's responses are considered success, promise is rejected only if an error occured during the transfer or while parsing the reponse's body (expected JSON)
Properties
abortTimeout
Syntax
abortTimeout
Number
Summary
Maximum time to wait until the request is aborted (in ms).
Default: 2000
executionTimeout
Syntax
executionTimeout
Number
Summary
Maximum execution time for the request (in ms).
Default: 10000
multiparted
Syntax
multiparted
Boolean
Summary
Indicates if request body must be sent as multipart/form-data.
Default: false
request
Syntax
request
ClientRequest
Summary
The HTTP(S) request.