Creates a RetryFunction that will retry a failed request the specified number of times, using the given exponential base as a falloff interval.
The number of times to retry the failed data operation before giving up.
The base number of milliseconds to use as the exponential falloff period. On each invocation of the retry function, the falloff period will be increased by a power of 2 and multiplied by this base. For example:
Invoked to determine whether the data operation should be retried.
Replaces tokens in a string with values from the provided lookup, and then appends any unmatched key-value pairs in the lookup as a querystring.
NOTE: Nested objects will not be serialized; if you need to pass complex objects to your endpoint, you should be doing it through the request body; alternatively, use JSON.stringify on the object yourself before passing it to serialize.
NOTE: different falsy values are treated differently when appending to the querystring:
input params | result string |
---|---|
{ key: false } |
key=false |
{ key: null } |
key |
{ key: undefined } |
(no output) |
A URL that may contain tokens in the :name
format. Any
tokens found in this format will be replaced with corresponding named values in
the params
argument.
Values to use to replace named tokens in the URL. Any unmatched values will be appended to the URL as a properly encoded querystring.
A tokenized string with additional URL-encoded values appened to the querystring.
Wraps a fetch method so a reauthentication method is invoked if a Response status 401 is returned. The reauthentication method is responsible for ensuring future requests are authenticated.
One way to do this is by adding a ProxyRule to the Proxy that sets an Authorize header to an updated value on specific Requests. A simpler approach is to rely on a Set-Cookie response header to update the cookies sent with future requests (if withCredentials is true).
The fetch method to wrap.
Method to invoke to reauthenticate the user.
The wrapped fetch method.
Wraps the fetch method to cache successful Responses within a data pipeline.
NOTE: You can easily create Store-backed data caches for this method using asDataCache().
The wrapped fetch method.
Invokes the specified method when a call is aborted (Response status = 0).
The fetch method to wrap.
Invoked when a data call is aborted.
The wrapped fetch method.
Wraps fetch to provide automatic retry functionality when the operation fails. You can provide pre-defined retry logic using existing RetryFunction factories or by passing your own custom RetryFunction to this method.
The operation to wrap.
Invoked to determine whether the data operation should be retried.
The wrapped fetch method.
Coordinates and synchronizes access to the data pipeline through the specified ManualResetSignal or AutoResetSignal.
The fetch method to wrap.
The ManualResetSignal or AutoResetSignal to use to synchronize data calls.
The wrapped fetch method.
Wraps the given fetch method to add optional request and response transformations to the data pipeline.
The fetch method to wrap.
The wrapped fetch method.
Adds Cross-Site Request Forgery protection to Requests made to the same origin where the app is hosted. For this to work, the server and client agree on a unique token to identify the user and prevent cross-site requests from being sent without the user's knowledge.
By default, this method reads the XSRF-TOKEN
cookie value sent by the server
and adds it as the X-XSRF-TOKEN
request header on any requests sent to the
same origin. You can configure the cookie and/or the header name by passing your
own values in the options
argument. You can also specify a whitelist of cross-origin
hostnames the header should be sent to (e.g. to subdomains of the host domain).
See XSRFOptions for details.
Read more about XSRF and implementation best practices here.
The fetch method to wrap.
Optional overrides for cookie and header names.
The wrapped fetch method.
Functionality used to customize a DataLayer pipeline.
A DataLayer provides only basic functionality for fetching data. These utility methods help you extend the data pipeline with powerful features. They work by wrapping the DataLayer's fetch() method to process Requests and Responses based on various conditions you supply.
You should use this same approach in your own applications to provide easy cross-cutting functionality for data operations.