Reference / @open-music-sdk/core / endpointNamespace
Function: endpointNamespace()
function endpointNamespace<F>(
fn,
client,
endpoints
): tEndpointNamespace<F>;Defined in: packages/core/src/endpoint.ts:628
Binds every function in endpoints to client: { getSong, getSongs } becomes an object whose getSong(id) and getSongs(ids) need no client and hand over what the answer holds. endpoints is an object of functions made here, such as a module of them; it is read once, and the namespace it gives cannot be changed.
Type Parameters
F
F extends object
Parameters
fn
string
The name of the function that is binding, for the errors, such as "catalog".
client
The client to bind to, from createClient or anything with request, paginate and storefront.
endpoints
F
The functions to bind, by name; whatever is no function with a bound on it is left out.
Returns
A frozen object with no prototype, holding each bound function under its name.
Throws
TypeError if client is no client, or endpoints is no object.