# sunset-header-interceptor

> [The Sunset HTTP Header draft](https://tools.ietf.org/html/draft-wilde-sunset-header-05)

Latest version **0.1.2** (published 2018-05-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install sunset-header-interceptor
pnpm add sunset-header-interceptor
yarn add sunset-header-interceptor
bun add sunset-header-interceptor
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2018-05-24 |
| First published | 2018-05-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Tyrone Tudehope |
| Maintainers | johnnynotsolucky |
| Keywords | http, http-headers, sunset, middleware, interceptor |

## Links

- npm: https://www.npmjs.com/package/sunset-header-interceptor
- Repository: https://github.com/johnnynotsolucky/sunset-header-interceptor
- Homepage: https://github.com/johnnynotsolucky/sunset-header-interceptor#readme
- Issues: https://github.com/johnnynotsolucky/sunset-header-interceptor/issues
- npm.io page: https://npm.io/package/sunset-header-interceptor

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.1.2 (latest) — 2018-05-24
- 0.1.1 — 2018-05-24
- 0.1.0 — 2018-05-24

## README

# Axios Sunset Header Interceptor

[The Sunset HTTP Header draft](https://tools.ietf.org/html/draft-wilde-sunset-header-05)

### Fetch Interceptor

```javascript
import sunsetInterceptor from 'sunset-header-interceptor'

const sunsetHandler = (response, sunset, extra) = {
  // Soon Thomas won't be really useful anymore.
}

fetch('https://foo.com/bar', { /* init props */ })
  .then(sunsetInterceptor(sunsetHandler))
  .then(...)
```

#### With [fetch-interceptors](https://www.npmjs.com/package/fetch-interceptors)

```javascript
import fetchInterceptors = from 'fetch-interceptors'
import sunsetInterceptor from 'sunset-header-interceptor'

const sunsetHandler = (response, sunset, extra) = {
  // Soon Thomas won't be really useful anymore.
}

const myFetch = fetchInterceptors(fetch, sunsetInterceptor(sunsetHandler))

myFetch('https://httpbin.org/get?foo=bar', { /* init props */ )
```

### Axios

```javascript
import sunsetInterceptor from 'sunset-header-interceptor'

const sunsetHandler = (response, sunset, extra) = {
  // Soon Thomas won't be really useful anymore.
}

axios.interceptors.response.use(sunsetInterceptor(sunsetHandler))
```

### Roll your own

```javascript
import interceptor from 'sunset-header-interceptor/interceptor'

const myDankSunsetInterceptor = interceptor(( // Extract headers from an arb response
  response // Response object returned by your HTTP request library
) => {
  return ... // Logic to extract header information from the response
}, ( // Sunset header handler, called if Sunset header found
  response, // Response from teh HTTP request if available
  sunset, // Date representing Thomas' inevitable demise
  { link, params } // link URI, and whatever other params were passed through
) => {
  // Tell someone about Thomas.
  // Note: Anything returned from here is thrown away. Like Thomas.
});

myDankSunsetInterceptor({ /* reponse data */ })
```

👋

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