Skip to main content

ApiResponse

Upgather SDK


Upgather SDK / ApiResponse

Class: ApiResponse

Represents an HTTP API response.

Remarks​

This class encapsulates the response received from an API call, including the status code, body, and originating request.

Constructors​

new ApiResponse()​

new ApiResponse(statusCode, body, request?): ApiResponse

Creates an instance of ApiResponse.

Parameters​

statusCode​

number

The HTTP status code.

body​

Json

The response body.

request?​

HttpRequest

The original request (optional).

Returns​

ApiResponse

Properties​

body​

body: Json

The body of the response.


request?​

optional request: HttpRequest

The request that generated this response (if available).


statusCode​

statusCode: number

The HTTP status code of the response.

Methods​

isClientError()​

isClientError(): boolean

Determines whether the response is a client error.

Returns​

boolean

True if the status code is in the 4xx range; otherwise, false.


isServerError()​

isServerError(): boolean

Determines whether the response is a server error.

Returns​

boolean

True if the status code is in the 5xx range; otherwise, false.


isSuccess()​

isSuccess(): boolean

Determines whether the response indicates a successful request.

Returns​

boolean

True if the status code is in the 2xx range; otherwise, false.