Reference / @open-music-sdk/core / tEndpoint
Interface: tEndpoint()<A, R, U, K>
Defined in: packages/core/src/endpoint.ts:19
A function for one endpoint. Called with a client it resolves to what Apple answered. bound(client) is the same call with the client fixed and the answer unwrapped, and is what an endpoint namespace is made of. unwrap says how, and is on the function so that a reader of it, or anything built over it, can tell a write from a read.
Type Parameters
A
A extends readonly unknown[]
R
R
U
U
K
tEndpoint(client, ...args): Promise<R>;Defined in: packages/core/src/endpoint.ts:34
Asks Apple, with client. Everything handed over is checked as the call is made, before Apple is asked, and a mistake is a TypeError naming the function. Which arguments there are is the function's own to say.
Parameters
client
The client to ask with.
args
...A
The function's own arguments, as it declares them: an id, a list of ids, a name, options.
Returns
Promise<R>
What Apple answered, parsed, as the function's answer type says.
Throws
TypeError if client is no client, an argument is not what it should be, or the collection's path could not be asked for as written; before this endpoint is asked.
Throws
AppleMusicError as client.request rejects with, _tag says which; or as client.storefront() rejects with, where the collection asks it.
Throws
The reason options.signal aborted with, when it does.
Throws
Whatever a token provider, store, schema, hook or rate limiter throws, as client.request passes it on.
Properties
bound
readonly bound: (client) => (...args) => U;Defined in: packages/core/src/endpoint.ts:43
The same call with the client fixed and the answer unwrapped as unwrap says. Binding checks the client and nothing else; the arguments are checked as the bound function is called. Beyond what the call throws, a resource or resources function rejects with an ApiError when a success is no object, or its data is there and is no list, and a resource function also when the success holds no resource; a pages function hands over an iterable that asks for nothing until a loop starts, and throws from the loop what client.paginate does, an ApiError for a page that is none among them.
Parameters
client
Returns
(...args) => U
unwrap
readonly unwrap: K;Defined in: packages/core/src/endpoint.ts:45
The kind the function was declared with: what its bound form hands over.