How to use axios-auth-refresh - 2 common examples

To help you get started, we’ve selected a few axios-auth-refresh examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CodeForPhilly / prevention-point / frontend / src / api / index.js View on Github external
const create = () => {
  const api = apisauce.create({
    baseURL: "/api",
  })

  createAuthRefreshInterceptor(api.axiosInstance, refreshAuthLogic(api))

  api.addRequestTransform(request => {
    if (!["/token/", "/token/verify/"].includes(request.url)) {
      const jwtAccess = cookieValue("JWT_ACCESS")
      if (jwtAccess) {
        request.headers.Authorization = `Bearer ${jwtAccess}`
      }
    }
  })

  return {
    createToken: createToken(api),
    verifyToken: verifyToken(api),
    getQueue: getQueue(api),
    postFrontDeskEvent: postFrontDeskEvent(api),
    getParticipants: getParticipants(api),
github CodeForPhilly / prevention-point / frontend / src / api / participantApi.js View on Github external
const create = () => {
  const accessToken = localStorage.getItem("JWT_ACCESS")

  const api = apisauce.create({
    baseURL: "/api",
    headers: { Authorization: `Bearer ${accessToken}` },
  })

  createAuthRefreshInterceptor(api.axiosInstance, refreshAuthLogic(api))

  const getParticipants = async () => {
    const response = await api.get("/participants/")
    return response
  }
  return {
    getParticipants,
  }
}

axios-auth-refresh

Axios plugin which makes it very easy to automatically refresh the authorization tokens of your clients

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis

Popular axios-auth-refresh functions