Skip to content

Instantly share code, notes, and snippets.

View yoochangoh's full-sized avatar
👋

Changoh Yoo yoochangoh

👋
View GitHub Profile
@yoochangoh
yoochangoh / axios.refresh_token.1.js
Created December 20, 2021 14:40 — forked from Godofbrowser/axios.refresh_token.1.js
Axios interceptor for refresh token when you have multiple parallel requests. Demo implementation: https://github.com/Godofbrowser/axios-refresh-multiple-request
// for multiple requests
let isRefreshing = false;
let failedQueue = [];
const processQueue = (error, token = null) => {
failedQueue.forEach(prom => {
if (error) {
prom.reject(error);
} else {
prom.resolve(token);