Kind: Class
Source: atloria-monorepo/packages/api-client/src/clients/RestClient.ts
REST client for making HTTP requests
Methods
| Method | Signature | Returns |
|---|---|---|
getInterceptors | getInterceptors() | InterceptorManager |
setToken | setToken(token: string) | void |
getToken | getToken() | string |
request | request(config: RequestConfig) | Promise<T> |
get | `get(path: string, params: Record<string, string | number |
post | post(path: string, body: unknown, config: Partial<RequestConfig>) | Promise<T> |
put | put(path: string, body: unknown, config: Partial<RequestConfig>) | Promise<T> |
patch | patch(path: string, body: unknown, config: Partial<RequestConfig>) | Promise<T> |
delete | delete(path: string, config: Partial<RequestConfig>) | Promise<T> |
Where it refuses work
RestClientstops the work withTimeoutErrorwhentimeoutController.signal.aborted.RestClientstops the work with an early return whenconfig.skipRetry, in 2 places.RestClientstops the work with an early return when!response.ok.RestClientstops the work with an early return when'statusCode' in error.
When something fails
RestClienthandles failure in 2 places: it lets it reach the caller in all 2.
Was this page helpful?