d2l-fetch-dedupe
v2.1.1
Published
Provides a middleware function for de-duplicating fetch requests for the same url+auth combination
Maintainers
Readme
d2l-fetch-dedupe
Provides a middleware function for de-duplicating fetch requests for the same url+auth combination
Setup
npm ciUsage
Reference the script in your html after your reference to d2l-fetch (see here for details on d2l-fetch):
Install d2l-fetch-dedupe via npm:
npm install d2l-fetch-dedupeimport { fetchDedupe } from 'd2l-fetch-dedupe';This will import the auth middleware
Dedupe
Install the dedupe middleware to d2lfetch via the use function and then start making your requests.
d2lfetch.use({name: 'dedupe' fn: fetchDedupe});
const response = await d2lfetch.fetch(
new Request('http://example.com/api/someentity/')
);Requests are deduped based on the combination of url and Authorization request header value.
Any request that matches an existing in-flight request based on this combination will not result
in a subsequent network request but will rather be given a promise that resolves to a clone of
the inflight request's Response.
Versioning and Releasing
This repo is configured to use semantic-release. Commits prefixed with fix: and feat: will trigger patch and minor releases when merged to main.
To learn how to create major releases and release from maintenance branches, refer to the semantic-release GitHub Action documentation.
