Skip to content

wdjungst/devise-axios

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

import { initMiddleware } from 'devise-axios'

initMiddleware()

You can also change the default auth url and options

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

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

This works with ReactNative as well. (What?)

import { AsyncStorage } from 'react-native'
import initMiddleware from 'devise-axios'

initMiddleware({ storage: AsyncStorage })

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published