Packages

@routess/api-client

HTTP client for the Routess API.

A thin wrapper over fetch with typed methods for the Routess API.

Exports

Entry pointUse it for
@routess/api-clientClient factory, adapters, services and API types

Usage

import { createApiClient } from "@routess/api-client";

const api = createApiClient({ baseUrl: import.meta.env.VITE_API_URL });

const me = await api.getProfile();
const routes = await api.getRoutes();

Error handling

All client methods throw ApiError on non-2xx responses. The error includes:

  • status: HTTP status code
  • code: machine-readable error code from the API
  • message: human-readable
  • fieldErrors?: for 422 validation errors

On this page