bmnepali / axios-refresh-multiple-request

A simple project to demonstrate how to refresh tokens for unauthorized requests sent in parallel (especially useful in single page applications))

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Axios refresh multiple parallel requests

This project was created due to comments i received from this gist

Installation

Clone the repository

git clone https://github.com/Godofbrowser/axios-refresh-multiple-request.git

Install dependencies

npm i

// or 

yarn

Start the build

npm run dev

// or 

yarn dev

Start the demo api server

npm run serve

// or 

yarn serve

When the index page is loaded, you will notice two alert dialogs. These are from 2 unauthorized request errors as we tried to request the api with invalid token. The script then sends a refresh token request to get new auth token after which the 2 requests that failed initially are then sent again, but this time with a new token gotten from the refresh token request. On success, you will notice the data was received and displayed on the webpage.

You can tweet @godofbrowser if you need to ask a question about this

About

A simple project to demonstrate how to refresh tokens for unauthorized requests sent in parallel (especially useful in single page applications))


Languages

Language:JavaScript 79.2%Language:HTML 20.8%