Class: AWS.Response

Inherits:
Object
  • Object
show all
Defined in:
lib/response.js

Overview

This class encapsulates the response information from a service request operation sent through AWS.Request. The response object has two main properties for getting information back from a request:

The data property

The response.data property contains the serialized object data retrieved from the service request. For instance, for an Amazon DynamoDB listTables method call, the response data might look like:

> resp.data
{ TableNames:
   [ 'table1', 'table2', ... ] }

The data property can be null if an error occurs (see below).

The error property

In the event of a service error (or transfer error), the response.error property will be filled with the given error data in the form:

{ code: 'SHORT_UNIQUE_ERROR_CODE',
  message: 'Some human readable error message' }

In the case of an error, the data property will be null. Note that if you handle events that can be in a failure state, you should always check whether response.error is set before attempting to access the response.data property.

See Also:

Data Properties collapse

Operation Properties collapse

HTTP Properties collapse

HTTP Properties collapse

Property Details

dataObject (readonly)

Note:

Inside of a AWS.Request~httpData event, this property contains a single raw packet instead of the full de-serialized service response.

Returns the de-serialized response data from the service.

Returns:

  • (Object)

    the de-serialized response data from the service.

errorError (readonly)

Note:

This attribute is only filled if a service or networking error occurs.

An structure containing information about a service or networking error.

Returns:

  • (Error)
    • code [String] a unique short code representing the error that was emitted.
    • message [String] a longer human readable error message
    • retryable [Boolean] whether the error message is retryable.
    • statusCode [Numeric] in the case of a request that reached the service, this value contains the response status code.
    • time [Date] the date time object when the error occurred.
    • hostname [String] set when a networking error occurs to easily identify the endpoint of the request.
    • region [String] set when a networking error occurs to easily identify the region of the request.

httpResponseAWS.HttpResponse (readonly)

Returns the raw HTTP response object containing the response headers and body information from the server.

Returns:

  • (AWS.HttpResponse)

    the raw HTTP response object containing the response headers and body information from the server.

redirectCountInteger (readonly)

Returns the number of redirects that were followed before the request was completed.

Returns:

  • (Integer)

    the number of redirects that were followed before the request was completed.

requestIdString (readonly)

Returns the unique request ID associated with the response. Log this value when debugging requests for AWS support.

Returns:

  • (String)

    the unique request ID associated with the response. Log this value when debugging requests for AWS support.

retryCountInteger (readonly)

Returns the number of retries that were attempted before the request was completed.

Returns:

  • (Integer)

    the number of retries that were attempted before the request was completed.

Method Details

hasNextPage() ⇒ Boolean

Returns whether more pages of data can be returned by further requests

Returns:

  • (Boolean)

    whether more pages of data can be returned by further requests

Since:

  • v1.4.0

nextPage(callback) ⇒ AWS.Request?

Creates a new request for the next page of response data, calling the callback with the page data if a callback is provided.

Callback (callback):

  • function(err, data) { ... }

    Called when a page of data is returned from the next request.

    Parameters:

    • err (Error)

      an error object, if an error occurred in the request

    • data (Object)

      the next page of data, or null, if there are no more pages left.

Returns:

  • (AWS.Request)

    the request object for the next page of data

  • (null)

    if no callback is provided and there are no pages left to retrieve.

Since:

  • v1.4.0