Skip to content

AjaxResult Class

The AjaxResult class represents the result of a REST API request and extends the Result class, implementing the IResult interface.

Constructor

ts
constructor(
	answer: AjaxResultParams,
	query: AjaxQuery,
	status: number
)
  • answer: AjaxResultParams - Response parameters.
  • query: AjaxQuery - The query that was executed.
  • status: number - Response status.

Methods

Note: The setData method is not supported in AjaxResult and will throw an error if attempted.

getData
ts
getData(): Payload<unknown>

Retrieves the data associated with the result.

isMore
ts
isMore(): boolean

Checks if there are more data to request.

getTotal
ts
getTotal(): number

Returns the total number of items.

getStatus
ts
getStatus(): number

Returns the response status.

getQuery
ts
getQuery(): AjaxQuery

Returns the query that was executed.

getNext
ts
getNext(
	http: TypeHttp
): Promise<false|AjaxResult>

Asynchronously retrieves the next result, if available.

ParameterTypeDescription
httpTypeHttpHTTP client to execute the query.

Returns a Promise that resolves to AjaxResult or false if no more data is available.

Data Types

AjaxResultParams

The AjaxResultParams type is used to represent the parameters of an API request result.

PropertyTypeDescription
errorstring|{error: string, error_description: string}Error or error object.
error_descriptionstringError description.
resultanyRequest result.
nextNumberStringNext item (if available).
totalNumberStringTotal number of items (if available).

AjaxQuery

The AjaxQuery type is used to represent an API request.

PropertyTypeDescription
methodstringRequest method.
params{}Request parameters.
startnumberStarting position.

Released under the MIT License.