Skip to content

RestClient

reference
1 min readUpdated

Kind: Class

Source: atloria-monorepo/packages/api-client/src/clients/RestClient.ts

REST client for making HTTP requests

Methods

MethodSignatureReturns
getInterceptorsgetInterceptors()InterceptorManager
setTokensetToken(token: string)void
getTokengetToken()string
requestrequest(config: RequestConfig)Promise<T>
get`get(path: string, params: Record<string, stringnumber
postpost(path: string, body: unknown, config: Partial<RequestConfig>)Promise<T>
putput(path: string, body: unknown, config: Partial<RequestConfig>)Promise<T>
patchpatch(path: string, body: unknown, config: Partial<RequestConfig>)Promise<T>
deletedelete(path: string, config: Partial<RequestConfig>)Promise<T>

Where it refuses work

  • RestClient stops the work with TimeoutError when timeoutController.signal.aborted.
  • RestClient stops the work with an early return when config.skipRetry, in 2 places.
  • RestClient stops the work with an early return when !response.ok.
  • RestClient stops the work with an early return when 'statusCode' in error.

When something fails

  • RestClient handles failure in 2 places: it lets it reach the caller in all 2.

Was this page helpful?

Download as PDF