https://github.com/godofbrowser/axios-refresh-multiple-request
A simple project to demonstrate how to simultaneously refresh tokens for unauthorized requests sent in parallel (especially useful in single-page applications)
https://github.com/godofbrowser/axios-refresh-multiple-request
api-client axios javascript
Last synced: about 1 year ago
JSON representation
A simple project to demonstrate how to simultaneously refresh tokens for unauthorized requests sent in parallel (especially useful in single-page applications)
- Host: GitHub
- URL: https://github.com/godofbrowser/axios-refresh-multiple-request
- Owner: Godofbrowser
- Created: 2019-10-04T00:39:57.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-11-17T12:59:23.000Z (over 1 year ago)
- Last Synced: 2025-03-25T15:08:13.367Z (over 1 year ago)
- Topics: api-client, axios, javascript
- Language: JavaScript
- Homepage:
- Size: 645 KB
- Stars: 34
- Watchers: 1
- Forks: 12
- Open Issues: 7
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Axios refresh multiple parallel requests
> This project was developed in response to feedback and discussions on this [gist](https://gist.github.com/Godofbrowser/bf118322301af3fc334437c683887c5f)
**Background:**
When the index page loads, you may encounter two alert dialogs. These are triggered by unauthorized request errors, caused by attempts to access the API with an invalid token. The application then automatically initiates a refresh token request to retrieve a new authentication token. Once the new token is obtained, the previously failed requests are retried with the updated credentials. Upon successful execution, the requested data is retrieved and seamlessly displayed on the webpage.
You can tweet [@godofbrowser](https://twitter.com/Godofbrowser) if you need to ask a question about this
## 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
```