Overview

Introduction to better-axios, its purpose, and its key features.

👋 Welcome to better-axios

better-axios is a lightweight and powerful wrapper around Axios that helps you write cleaner, more consistent API calls across your frontend or backend projects.

🚀 Why use better-axios?

  • ✅ Unified request/response types (ApiResponse, ApiError)
  • 🔐 Easy token management (setAuthToken, removeAuthToken)
  • ⚙️ Global success & error handlers
  • 🧩 Easily extendable Axios instance
  • 📦 Works with React, Next.js, Node.js, etc.

🎯 Goal

The goal is to abstract away repetitive axios boilerplate, make it type-safe, and provide a plug-and-play interface for building API layers in TypeScript projects.


✨ Example Use

import { AxiosApi } from "better-axios";

const api = new AxiosApi({ baseURL: "https://api.example.com" });

const result = await api.get("/users");

if (result.success) {
  console.log(result.data); // ✅ success
} else {
  console.error(result.error.message); // ❌ error
}

This is just scratching the surface — check the Usage section for more.