Skip to main content

ApiResponse

Upgather SDK


Upgather SDK / ApiResponse

Class: ApiResponse

Defined in: lib/core/ApiResponse.ts:11

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

Defined in: lib/core/ApiResponse.ts:26

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

Defined in: lib/core/ApiResponse.ts:15

The body of the response.


request?

optional request: HttpRequest

Defined in: lib/core/ApiResponse.ts:17

The request that generated this response (if available).


statusCode

statusCode: number

Defined in: lib/core/ApiResponse.ts:13

The HTTP status code of the response.

Methods

isClientError()

isClientError(): boolean

Defined in: lib/core/ApiResponse.ts:46

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

Defined in: lib/core/ApiResponse.ts:55

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

Defined in: lib/core/ApiResponse.ts:37

Determines whether the response indicates a successful request.

Returns

boolean

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