Documentation Index
Fetch the complete documentation index at: https://mintlify.com/TheSerchCp/SEAM/llms.txt
Use this file to discover all available pages before exploring further.
ApiClient is a thin but opinionated wrapper around the browser’s native fetch() API. Rather than scattering authentication headers, error handling, and JSON serialization across every repository file, ApiClient centralizes all of that logic in a single request() method. Repositories call the convenience methods (get, post, put, delete) and work purely with resolved data — they never touch raw Response objects or Authorization headers.
Base URL
The API root is defined once injs/config/api.js and imported by both ApiClient and EventBus:
ApiClient methods is appended to this base, so /users becomes http://localhost:3001/api/v1/users.
Convenience Methods
These four methods are the public API consumed by repository files. Each one delegates to the sharedrequest() method.
| Method | Signature | HTTP Verb |
|---|---|---|
get | get(path) | GET |
post | post(path, body) | POST |
put | put(path, body) | PUT |
delete | delete(path, body) | DELETE |
request(method, path, body)
All four convenience methods are one-liners that call request(). Understanding request() means understanding every HTTP interaction in the application.
The HTTP verb for the request.
The API path relative to
API_BASE, including a leading slash. Supports path parameters inline: '/users/5'.JSON-serializable request body. Only meaningful for
POST and PUT. Defaults to null.What request() does — step by step
Attach Authorization header
Reads
session.token and, if present, sets Authorization: Bearer {token} on the request headers. Unauthenticated requests (e.g. /auth/login) go through without a token.Attach X-Socket-ID header
Reads
EventBus.socketId and adds the X-Socket-ID header when a socket is active. The server uses this to direct operation:progress events to the correct tab.Serialize the body
If
body is not null, it is serialized with JSON.stringify() and placed in config.body.Execute the fetch
Calls
fetch(API_BASE + path, config) and attempts to parse the response as JSON. A failed JSON parse yields an empty object rather than throwing.Handle HTTP errors
If
res.ok is false, an error toast is emitted (for non-GET requests) and an Error is thrown with payload.message as the message.Network Errors
Iffetch() itself throws (e.g. the server is unreachable), the TypeError is caught and a connection-error toast is emitted before re-throwing:
Full request() source
The X-Socket-ID Header
The
X-Socket-ID header solves a fan-out problem in real-time applications: when a user in one tab creates a resource, the server emits both a data:changed event (broadcast to all tabs) and an operation:progress event (targeted feedback for the initiating tab only). By receiving the socket ID on the request, the server can skip sending operation:progress to other open tabs belonging to the same user — those tabs receive only data:changed and refresh their data silently.EventBus.socketId, which proxies the underlying io().id assigned by the Socket.IO server at connect time.
Repository Usage Examples
Repositories are thin modules that callApiClient and return the resulting data. They do not handle headers, tokens, or toasts — that is ApiClient’s job.