Reference / @open-music-sdk/browser / tBrowserClientOptions
Interface: tBrowserClientOptions
Defined in: integrations/browser/src/client.ts:11
Invalid values throw a TypeError when the client is made.
Extends
Omit<tClientOptions,"developerToken">
Properties
endpoint?
readonly optional endpoint?: tFetcherOptions;Defined in: integrations/browser/src/client.ts:24
The endpoint's own options: a fetch for it, with the credentials or headers it needs, timeoutMs, and refreshAheadSeconds. The client's own fetch is for Apple, and never reaches the endpoint; this one is for the endpoint, and never reaches Apple.
fetch?
optional fetch?: {
(input, init?): Promise<Response>;
(input, init?): Promise<Response>;
};Defined in: packages/core/src/client.ts:107
What sends each request. Default: the global fetch.
Call Signature
(input, init?): Promise<Response>;Parameters
input
URL | RequestInfo
init?
RequestInit
Returns
Promise<Response>
Call Signature
(input, init?): Promise<Response>;Parameters
input
string | Request | URL
init?
RequestInit
Returns
Promise<Response>
Inherited from
Omit.fetchonRequest?
optional onRequest?: (req) => void;Defined in: packages/core/src/client.ts:116
Called just before each attempt is sent, with the final Request. Its headers hold the developer token and, where it is sent, the Music User Token, so a hook that logs requests logs both tokens.
Parameters
req
Request
Returns
void
Inherited from
Omit.onRequestonResponse?
optional onResponse?: (res, req, outcome) => void;Defined in: packages/core/src/client.ts:123
Called once per response, after the client is done with it: the body has been read and the outcome decided. outcome.error is what the request will throw unless a retry succeeds. The body has been read, so take it from outcome.body, not from res.json(). req is the Request onRequest is handed, token headers and all, so a hook that logs it logs the tokens.
Parameters
res
Response
req
Request
outcome
Returns
void
Inherited from
Omit.onResponserateLimit?
optional rateLimit?: tRateLimiter;Defined in: packages/core/src/client.ts:111
Opt-in token bucket. Share one instance across every client using the same developer token.
Inherited from
Omit.rateLimitretry?
optional retry?: false | tRetryPolicy;Defined in: packages/core/src/client.ts:109
false disables retries; a plain object sets the policy field by field. Default: 2 attempts, 250 ms base, 4 s cap, full jitter, Retry-After honoured.
Inherited from
Omit.retrystorefront?
optional storefront?: string;Defined in: packages/core/src/client.ts:105
Catalog storefront, by its id, such as "us": one segment of a path. Without it, storefront() resolves the listener's from /v1/me/storefront.
Inherited from
Omit.storefronttokenUrl
readonly tokenUrl: string | URL;Defined in: integrations/browser/src/client.ts:18
Where tokenEndpoint of @open-music-sdk/server is mounted. A relative URL resolves against the page's address when the client is made, and stays there: a route the page moves to later, a <base> put into it later, or a change to the URL object later, moves nothing. Where there is no page, as in a server render, a relative URL is left to resolve at the first fetch, which rejects with a TypeError where there is still no page.
userToken?
optional userToken?: string | tTokenProvider;Defined in: packages/core/src/client.ts:101
Binds the client to one listener. Alternatively set userTokenStore and use forUser().
Inherited from
Omit.userTokenuserTokenStore?
optional userTokenStore?: tUserTokenStore;Defined in: packages/core/src/client.ts:103
Where forUser() finds a listener's token. Needs get, set and delete; the client itself calls only get.
Inherited from
Omit.userTokenStore