Skip to content
Client
Server

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

Interface: tRequestInit<T> ​

Defined in: packages/core/src/client.ts:139

What request sends beside the path, and what it makes of the answer. Every field is optional. It is read as its own properties, once, when the request is made, and sent as it is: a caller's options are checked by initOf, and a function for an endpoint hands over what it made of them. What cannot be encoded is a TypeError from the request.

Extended by ​

Type Parameters ​

T ​

T = unknown

Properties ​

body? ​

ts
readonly optional body?: unknown;

Defined in: packages/core/src/client.ts:145

JSON-encoded, and sent with Content-Type: application/json.


method? ​

ts
readonly optional method?: "POST" | "GET" | "PUT" | "DELETE";

Defined in: packages/core/src/client.ts:141

The HTTP method. Default: GET.


onResponse? ​

ts
readonly optional onResponse?: (res, req, outcome) => void;

Defined in: packages/core/src/client.ts:158

Called as the client's own onResponse is, and after it, for this request alone: once per response, when the body has been read and the outcome decided. It is how a caller learns what request does not resolve to, such as the status of the answer or one of its headers. req is the Request as sent, token headers and all, so a hook that logs it logs the tokens.

Parameters ​

res ​

Response

req ​

Request

outcome ​

tResponseOutcome

Returns ​

void


params? ​

ts
readonly optional params?: Readonly<Record<string, 
  | string
  | number
  | boolean
  | readonly (string | number)[]
  | null
| undefined>>;

Defined in: packages/core/src/client.ts:143

The query, encoded as tParams says and set on the URL over whatever the path carries.


schema? ​

ts
readonly optional schema?: tSchemaLike<T>;

Defined in: packages/core/src/client.ts:149

Validates the parsed body; a failure throws ValidationError.


signal? ​

ts
readonly optional signal?: AbortSignal;

Defined in: packages/core/src/client.ts:151

Aborts the request at any point: before an attempt, in the rate limiter, in fetch, reading the body, or between attempts. Its reason is what the request then rejects with, as it is.


user? ​

ts
readonly optional user?: boolean;

Defined in: packages/core/src/client.ts:147

Send the Music User Token. Default: true under /v1/me.

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