# RestClient

**Kind:** Class

**Source:** [`atloria-monorepo/packages/api-client/src/clients/RestClient.ts`](https://github.com/sherkety/atloria/blob/main/atloria-monorepo/packages/api-client/src/clients/RestClient.ts#L20)

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 | boolean | undefined>, config: Partial<RequestConfig>)` | `Promise<T>` |
| `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

- `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.
