Skip to content

PURISTA API / Modules / @purista/core / RestClient

Interface: RestClient

@purista/core.RestClient

A REST API client which will provide GET, POST, PUT, PATCH, DELETE methods The client provides error and timeout handling and tries to decode the responses

Implemented by

Table of contents

Methods

Methods

delete

delete<T>(path, options): Promise<T>

Make a DELETE request against baseUrl+path Returns body text if response content type is not set to application/json. If response content type is application/json, the JSON parsed result will be returned

Type parameters

Name
T

Parameters

NameType
pathstring
optionsHttpClientRequestOptions

Returns

Promise<T>

Defined in

HttpClient/types/RestClient.ts:60


get

get<T>(path, options): Promise<T>

Make a GET request against baseUrl+path Returns body text if response content type is not set to application/json. If response content type is application/json, the JSON parsed result will be returned

Type parameters

Name
T

Parameters

NameType
pathstring
optionsHttpClientRequestOptions

Returns

Promise<T>

Defined in

HttpClient/types/RestClient.ts:21


patch

patch<T>(path, payload, options): Promise<T>

Make a PATCH request against baseUrl+path Returns body text if response content type is not set to application/json. If response content type is application/json, the JSON parsed result will be returned

Type parameters

Name
T

Parameters

NameType
pathstring
payloadunknown
optionsHttpClientRequestOptions

Returns

Promise<T>

Defined in

HttpClient/types/RestClient.ts:51


post

post<T>(path, payload, options): Promise<T>

Make a POST request against baseUrl+path Returns body text if response content type is not set to application/json. If response content type is application/json, the JSON parsed result will be returned

Type parameters

Name
T

Parameters

NameType
pathstring
payloadunknown
optionsHttpClientRequestOptions

Returns

Promise<T>

Defined in

HttpClient/types/RestClient.ts:31


put

put<T>(path, payload, options): Promise<T>

Make a PUT request against baseUrl+path Returns body text if response content type is not set to application/json. If response content type is application/json, the JSON parsed result will be returned

Type parameters

Name
T

Parameters

NameType
pathstring
payloadunknown
optionsHttpClientRequestOptions

Returns

Promise<T>

Defined in

HttpClient/types/RestClient.ts:41


setBearerToken

setBearerToken(token): void

Set the Auth-Bearer-Token for all following requests

Parameters

NameTypeDescription
tokenundefined | stringthe bearer token

Returns

void

Defined in

HttpClient/types/RestClient.ts:12