Docs
Types

WP_CallOptions

Override headers, cancellation, or timeout for one generated endpoint call.

WP_CallOptions is the optional second argument on every generated WordPress endpoint. Its values apply only to that request.

Prop

Type

OptionTypeEffect
headersRecord<string, string>Add or override request headers.
signalAbortSignalCancel the request from an existing controller or signal.
timeoutDurationOverride the transport timeout with milliseconds or a duration string such as "5 seconds".
const controller = new AbortController()

await context.wordpress.postTypes.post.retrieve(
  { identifier: "featured" },
  {
    headers: { "X-Request-Source": "homepage" },
    signal: controller.signal,
    timeout: "5 seconds",
  },
)

Pass an empty input object first when an endpoint has no required input but still needs call options.