# d2l-fetch-dedupe

> Provides a middleware function for de-duplicating fetch requests for the same url+auth combination

Latest version **2.1.1** (published 2024-11-25) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install d2l-fetch-dedupe
pnpm add d2l-fetch-dedupe
yarn add d2l-fetch-dedupe
bun add d2l-fetch-dedupe
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2024-11-25 |
| First published | 2019-01-08 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | D2L Corporation |
| Maintainers | d2l-travis-deploy |
| Keywords | fetch, middleware, auth |

## Links

- npm: https://www.npmjs.com/package/d2l-fetch-dedupe
- npm.io page: https://npm.io/package/d2l-fetch-dedupe

## Alternatives

- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads
- [escher-request](https://npm.io/package/escher-request.md) — 545 weekly downloads

## Recent versions

- 2.1.1 (latest) — 2024-11-25
- 2.1.0 — 2024-01-11
- 2.0.0 — 2023-03-27
- 1.3.0 — 2020-05-26
- 1.2.0 — 2020-05-21
- 1.1.0 — 2019-01-09
- 1.0.0 — 2019-01-09
- 0.16.0 — 2019-01-08

## README

# d2l-fetch-dedupe
Provides a middleware function for de-duplicating fetch requests for the same url+auth combination

## Setup

```sh
npm ci
```

## Usage

Reference the script in your html after your reference to `d2l-fetch` (see [here](https://github.com/Brightspace/d2l-fetch) for details on d2l-fetch):

Install `d2l-fetch-dedupe` via npm:
```sh
npm install d2l-fetch-dedupe
```

```javascript
import { 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.

```js
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](https://github.com/BrightspaceUI/actions/tree/main/semantic-release) documentation.

---
_Source: https://npm.io/package/d2l-fetch-dedupe · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
