← All open source projects

Axios

axios/axios

Axios is a JavaScript HTTP client for browsers and Node.js with promises, interceptors, and request configuration.

Forks 11,721
Author axios
Language JavaScript
License MIT
Synced 2026-06-07

What it is

Axios is a library for HTTP requests from browsers and Node.js. It appeared before `fetch` became the familiar standard and remains useful when requests need to be centrally configured rather than simply sent.

The library is promise-based, can create separate client instances, supports request and response interceptors, cancellation through AbortController, data transforms, file uploads, progress, and detailed header configuration.

How it appeared and why it stuck

In large JavaScript applications, HTTP requests quickly turn into repeated code: base URLs, tokens, error handling, timeouts, and repeated headers. Axios became popular because it wrapped that routine in a convenient API.

Even after `fetch` became common, Axios kept a place. It provides one API for browser and Node.js usage, a familiar response shape, interceptors, and many patterns teams have used for years.

What is inside

The repository contains the client source, adapters, types, tests, and documentation for request configuration, error handling, cancellation, form serialization, and HTTP/2.

Client instance with an interceptor

This example shows a common pattern: one client stores the base URL, while an interceptor adds a header before each request.

Language: JavaScript
import axios from "axios";

const api = axios.create({
  baseURL: "https://api.example.com",
  timeout: 5000
});

api.interceptors.request.use((config) => {
  config.headers.Authorization = `Bearer ${localStorage.getItem("token")}`;
  return config;
});

const { data } = await api.get("/profile");

Where it helps

Axios helps in applications with many requests and shared behavior: authorization, error handling, retries, timeouts, file uploads, and forms.

If an app makes one simple GET request, standard `fetch` is enough. But when requests become part of application architecture, a separately configured client is often cleaner.

Strengths and limits

The strength is a mature API and predictable HTTP wrapper. Teams get one way to describe requests and responses across environments.

The limitation is that it is an extra dependency on top of the platform. New projects should compare Axios with `fetch` deliberately: sometimes the library is justified, sometimes the standard API is enough.