withHeaders
Sets static default headers for HTTP and SSE requests built by this client.
@defjs/core · Function
Signature
function withHeaders(headers: HeadersInit): ClientOption;
WebSocket connections do not use them. The HeadersInit is copied into a Headers object when the option is applied. A later call replaces the earlier headers instead of merging.
Headers returned by a request builder replace a default of the same name. The first value for that name replaces the default; later values in the same array append only to that replacement. A scalar or a Headers instance also replaces. Other default names stay.
Per-request or computed credentials, such as a refreshed Bearer token or an HMAC signature, belong in an interceptor, because they need the serialized body or a refreshed credential.
Parameters
Prop
Type
headers HeadersInitHeadersInit bag cloned onto the client config.
Returns
An option that writes config.headers.