Skip to content
Client
Server

Reference / @open-music-sdk/core / resourceGetter

Function: resourceGetter() ​

ts
function resourceGetter<R, C, E>(
   fn, 
   collection, 
   ...also
): tEndpoint<[id: string, options?: tEndpointOptions<R, C, E>], R, Promise<tItem<R>>, "resource">;

Defined in: packages/core/src/endpoint.ts:414

A function for the resource with one id in a collection: GET {collection}/{id}. R is the answer's type and has to be said. also names the options of E, the ones the function takes beyond everyone's and the collection's.

The function it gives takes an id and options, checks the id as one segment of a path and the options as tEndpointOptions, and throws and resolves as tEndpoint says. Bound, it hands over the one resource.

Type Parameters ​

R ​

R extends tResources = never

C ​

C extends object = object

E ​

E extends object = object

Parameters ​

fn ​

string

The function's name, as its errors say it.

collection ​

tCollectionGiven<R, C>

Where the resources are: the path with nothing after it, or how to ask the client for it.

also ​

...tAlsoGiven<E>

What each option of E is, a "list" or a "name"; left out when E names none.

Returns ​

tEndpoint<[id: string, options?: tEndpointOptions<R, C, E>], R, Promise<tItem<R>>, "resource">

The function, frozen, with bound and unwrap on it.

Throws ​

TypeError if fn is not a string with something in it, collection is no function, its user is given and is no boolean, or also is not an object that says "list" or "name" for each option.

MIT licensed. Not affiliated with, endorsed by, or sponsored by Apple Inc. Apple Music and MusicKit are trademarks of Apple Inc.