Skip to content

Instantly share code, notes, and snippets.

View EmekaManuel's full-sized avatar
🏠
Working from home

Onyewuchi Emmanuel EmekaManuel

🏠
Working from home
View GitHub Profile
@import url("https://fonts.googleapis.com/css?family=Roboto+Slab:100,300,400,700");
@import url("https://fonts.googleapis.com/css?family=Raleway:300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i");
* {
margin: 0;
border: 0;
box-sizing: border-box;
}
:root {
@EmekaManuel
EmekaManuel / Advanced Typescript Axios Interceptor with [JWT] Authentication, Error Handling, Retry Mechanism and API request helper methods
Last active March 14, 2025 09:19
Advanced Typescript Axios Interceptor with [JWT] Authentication, Error Handling, Retry Mechanism and API request helper methods : This TypeScript-based API wrapper extends Axios to handle authentication, token expiration, request retries, and network monitoring. It includes: JWT Authentication: Token decoding, expiration checks, and automatic lo…
/* eslint-disable @typescript-eslint/no-explicit-any */
import axios, { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';
import { jwtDecode } from 'jwt-decode';
// Define interfaces
interface DecodedToken {
roles: string[];
sub: string; // email
iat: number; // issued at timestamp
exp: number; // expiry timestamp