# devise-axios

> Middleware for keeping track of devise token auth tokens on authenticated requests

Latest version **1.0.24** (published 2018-09-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install devise-axios
pnpm add devise-axios
yarn add devise-axios
bun add devise-axios
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.24 |
| Published | 2018-09-26 |
| First published | 2018-08-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 109.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 22 |
| Author | Dave Jungst |
| Maintainers | djungst |

## Links

- npm: https://www.npmjs.com/package/devise-axios
- Repository: https://github.com/wdjungst/devise-axios
- Homepage: https://github.com/wdjungst/devise-axios#readme
- Issues: https://github.com/wdjungst/devise-axios/issues
- npm.io page: https://npm.io/package/devise-axios

## Dependencies (1)

- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.0.0

## Recent versions

- 1.0.24 (latest) — 2018-09-26
- 1.0.23 — 2018-09-21
- 1.0.22 — 2018-09-21
- 1.0.21 — 2018-09-21
- 1.0.20 — 2018-09-21
- 1.0.19 — 2018-09-21
- 1.0.18 — 2018-09-21
- 1.0.17 — 2018-09-21
- 1.0.16 — 2018-09-21
- 1.0.15 — 2018-09-20
- 1.0.14 — 2018-09-20
- 1.0.13 — 2018-09-20
- 1.0.12 — 2018-08-21
- 1.0.11 — 2018-08-21
- 1.0.10 — 2018-08-21
- … 12 more at https://npm.io/package/devise-axios/versions

## README

# About

This package fits a very specific use case.  Its purpose is to help keep track of new tokens everytime a request is made.  It works by capturing the axios response and hot swapping tokens if new tokens have come back from the server.  On an authenticated request, tokens are destroyed on signout and tokens are rehydrated on a validation event.

 * You are using devise token authentication
 * You are using axios
 
# Installation
```npm install devise-axios```

```javascript
import { initMiddleware } from 'devise-axios'

initMiddleware()
```

You can also change the default auth url and options

```javascript
  //defaults
  //{
  //  authPrefix: '/api/auth',
  //  signOut: '/sign_out',
  //  validate: '/validate_token',
  //}

  const options = { authPrefix: '/auth' }
  initMiddleware(options)
```

This works with ReactNative as well. (What?)
```javascript
import { AsyncStorage } from 'react-native'
import initMiddleware from 'devise-axios'

initMiddleware({ storage: AsyncStorage })
```

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