Class: Request

openveo-rest-nodejs-client/Request~Request(protocol, optionsopt, bodyopt, timeoutopt, multipartedopt)

Request

Constructor

new Request(protocol, optionsopt, bodyopt, timeoutopt, multipartedopt)

Creates a REST request which can be executed / aborted.

Parameters:
Name Type Attributes Default Description
protocol String

The protocol to use for the request (either 'http' or 'https')

options Object <optional>

The 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 <optional>

The request body

timeout Number <optional>
10000

Maximum execution time for the request (in ms), set it to Infinity for a request without limits

multiparted Boolean <optional>
false

true to send body as multipart/form-data

Source:
Throws:

Thrown if protocol is not valid or options is not a valid object

Type
TypeError

Members

abortTimeout :Number

Maximum time to wait until the request is aborted (in ms).

Type:
  • Number
Default Value:
  • 2000
Source:

accessToken :String

Application access token provided by the web service.

Type:
  • String
Source:

attempts :Number

The number of attempts made on this request.

Type:
  • Number
Default Value:
  • 0
Source:

(readonly) body :String

The request body.

Type:
  • String
Source:

(readonly) certificate :String

Path to the web service server certificate file.

Type:
  • String
Source:

executionTimeout :Number

Maximum execution time for the request (in ms).

Type:
  • Number
Default Value:
  • 10000
Source:

(readonly) hostname :String

Web service server host name.

Type:
  • String
Source:

isRunning :Boolean

Indicates if request is actually running.

Type:
  • Boolean
Default Value:
  • false
Source:

maxAuthenticationAttempts :Number

Maximum number of authentication attempts to perform on a request in case of an invalid or expired token.

Type:
  • Number
Default Value:
  • 1
Source:

multiparted :Boolean

Indicates if request body must be sent as multipart/form-data.

Type:
  • Boolean
Default Value:
  • false
Source:

(readonly) options :Object

Request options.

Type:
  • Object
Source:

(readonly) path :String

Web service URL path.

Type:
  • String
Source:

(readonly) port :Number

Web service server port.

Type:
  • Number
Source:

(readonly) protocol :String

Request protocol either "http" or "https".

Type:
  • String
Source:

(readonly) protocol :String

Web service protocol, either "http" or "https".

Type:
  • String
Source:

queuedRequests :Set

The collection of queued requests waiting to be executed.

Type:
  • Set
Source:

request :Object

The HTTP(S) request.

Type:
  • Object
Source:
See:

Methods

(async) abort() → {Promise}

Aborts the request.

Source:
Returns:

Promise resolving when request has been aborted, promise is rejected if it takes too long to abort the request

Type
Promise

(async) execute(headersopt) → {Promise}

Executes the request.

Be careful, if request is executed while still running, the running one will be aborted.

Parameters:
Name Type Attributes Description
headers Object <optional>

A list of http(s) headers. Headers will be merged with Request headers set in the constructor. It takes priority over Request headers.

Source:
Throws:

Thrown if options is not a valid object

Type
TypeError
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)

Type
Promise