RequestOptions
Every REST resource method accepts a trailing requestOptions argument that
controls the transport for that one call: how long to wait, whether to retry,
how to back off, and an AbortSignal to cancel. Pass the same object as the
requestOptions option of the RestClient constructor to set a
client-wide default. A per-request value overrides the client default field by
field; an unset field inherits.
Pass a plain object literal, typed as RequestOptionsInit. The RequestOptions
class is exported too and is accepted anywhere the plain object is.
Properties
timeout
Maximum seconds per attempt. When exceeded, the request throws a
RestTransportError (see RestError).
retries
Number of retry attempts after the first failure, so total attempts are
retries + 1. Retries are off by default.
retryOnStatus
HTTP statuses that trigger a retry. Defaults to 429, 500, 502, 503,
and 504. GET, PUT, and DELETE retry on any status in the set.
POST and PATCH retry only on 429 and 503, which mean the request was
not processed, so a partially applied write is never replayed.
retryBackoff
Base seconds for exponential backoff between retries, doubling each attempt.
A Retry-After response header is honored when present.
abortSignal
Cancels the request. The signal is passed straight to fetch, so an
in-flight request is interrupted, and it is checked again before every retry.
Examples
Client-wide default
Per-request override with cancellation
Retries on every page of an iteration
paginate() forwards the same requestOptions to every page fetch.