Configure the client
Configure the Ovok API origin, tenant, storage, and request behavior.
- Stable unknown
- Release candidate since 0.4.49-rc.2
- Development since 0.4.49-dev.493+062a3db
Create Ovok from the package root and pass the API origin and tenant code:
import { Ovok } from '@ovok/core';
const ovok = new Ovok({
baseUrl: 'https://api.sandbox.ovok.com',
tenantCode: 'your-tenant',
fhirPath: 'fhir/R4',
});baseUrl must be an absolute HTTP(S) URL. tenantCode is required. fhirPath defaults to fhir; leading and trailing slashes are removed before requests.
Storage and requests
- Session storage: the session lives in memory by default. Pass any
OvokStorage(localStorage, AsyncStorage, or your owngetItem/setItem/removeItem) to keep users signed in across restarts. - Requests:
timeoutMsandmaxNetworkRetriestune every request;fetchreplaces the runtimefetch. - Sign-out notice:
onUnauthenticatedruns when a refresh token is refused and the user has been signed out. - Outbox:
outboxStorekeeps unsent measurements (memory by default;IndexedDbOutboxStorein a browser),connectivityandlifecycletell it when to send,outboxRequestBudgetcaps its requests per 30 seconds (40 by default) andloggerreceives its structured log entries. See ovok.outbox.
Every option, its type and its default is listed in the Ovok client reference. Keep persisted session data protected as your app's security requirements demand.
Machine credentials
Server applications may supply both clientId and clientSecret for machine authentication. Never put clientSecret in browser or mobile application code; the client rejects it when running in a browser.
A server that only reads published CMS content can pass cmsApiKey instead: a read-only key sent as x-api-key on ovok.cms reads, with no session. It is a secret too, and rejected in a browser the same way. See ovok.cms.
Use a resource namespace
The client groups operations by API domain. For example, FHIR searches use ovok.fhir:
const patients = await ovok.fhir.search('Patient', { _count: 10 });See also
- The Ovok client: paging and request options.
- Errors and retries: error classes.
- Ovok client reference
Last updated on