Class: APIRequest

APIRequest(config, eventBus)

APIRequest helps to prepare and execute requests to the Box API. It supports retries, multipart uploads, and more.

Constructor

new APIRequest(config, eventBus)

Parameters:
Name Type Description
config Config Request-specific Config object
eventBus EventEmitter Event bus for the SDK instance
Source:

Methods

(private) _finish(errnullable, response) → {void}

Propagate the response to the provided callback.
Parameters:
Name Type Attributes Description
err Error <nullable>
An error, if one occurred
response APIRequest~ResponseObject Information about the request & response
Source:
Returns:
Type
void

(private) _finish(errnullable, response) → {void}

Propagate the response to the provided callback.
Parameters:
Name Type Attributes Description
err Error <nullable>
An error, if one occurred
response APIRequest~ResponseObject Information about the request & response
Source:
Returns:
Type
void

(private) _handleResponse(errnullable, responseopt) → {void}

Handle the request response in the callback case.
Parameters:
Name Type Attributes Description
err Error <nullable>
An error, if one occurred
response Object <optional>
The full response object, returned by the request module. Contains information about the request & response, including the response body itself.
Source:
Returns:
Type
void

(private) _handleResponse(errnullable, responseopt) → {void}

Handle the request response in the callback case.
Parameters:
Name Type Attributes Description
err Error <nullable>
An error, if one occurred
response Object <optional>
The full response object, returned by the request module. Contains information about the request & response, including the response body itself.
Source:
Returns:
Type
void

(private) _retry(errnullable) → {void}

Attempt a retry. If the request hasn't exceeded it's maximum number of retries, re-execute the request (after the retry interval). Otherwise, propagate a new error.
Parameters:
Name Type Attributes Description
err Error <nullable>
An error, if one occurred
Source:
Returns:
Type
void

(private) _retry(errnullable) → {void}

Attempt a retry. If the request hasn't exceeded it's maximum number of retries, re-execute the request (after the retry interval). Otherwise, propagate a new error.
Parameters:
Name Type Attributes Description
err Error <nullable>
An error, if one occurred
Source:
Returns:
Type
void

execute(callbackopt) → {void}

Executes the request with the given options. If a callback is provided, we'll handle the response via callbacks. Otherwise, the response will be streamed to via the stream property. You can access this stream with the getResponseStream() method.
Parameters:
Name Type Attributes Description
callback APIRequest~Callback <optional>
Callback for handling the response
Source:
Returns:
Type
void

execute(callbackopt) → {void}

Executes the request with the given options. If a callback is provided, we'll handle the response via callbacks. Otherwise, the response will be streamed to via the stream property. You can access this stream with the getResponseStream() method.
Parameters:
Name Type Attributes Description
callback APIRequest~Callback <optional>
Callback for handling the response
Source:
Returns:
Type
void

getResponseStream() → (nullable) {ReadableStream}

Return the response read stream for a request. This will be undefined until a stream-based request has been started.
Source:
Returns:
The response stream
Type
ReadableStream

getResponseStream() → (nullable) {ReadableStream}

Return the response read stream for a request. This will be undefined until a stream-based request has been started.
Source:
Returns:
The response stream
Type
ReadableStream