axios
FreeNo executable scriptsNot checkedAxios is a promise-based HTTP client for Node.js and browsers that sends requests, parses JSON, and rejects on error status codes. Use it when asked to "call…
by TerminalSkills★ 221 GitHub starsAbout this skill
Axios — promise-based HTTP client
Overview
Axios (npm package axios, current major 1.x) wraps HTTP requests behind one API that works in Node.js and in browsers. It serializes request bodies, parses JSON responses into response.data, and rejects the promise for non-2xx statuses. Its main features are configured instances, request and response interceptors, cancellation with AbortSignal, per-request timeouts, and pluggable adapters (http, xhr, fetch). The package is ESM with a CommonJS build.
Instructions
Installation and version safety
npm install axios
npm view axios version # confirm what latest is
npm ls axios # find every copy in the tree
Axios has had many security advisories, most of them in proxy handling, prototype-pollution gadgets and body-size limits. Fixes for all those listed in the GitHub advisory database at the time of writing are in 1.20.0, so use 1.20.0 or newer (1.21.0 was latest when this skill was written). On the 0.x line the last release is 0.34.0.
Versions 1.14.1 and 0.30.4 were published with malicious code: a hidden dependency, plain-crypto-js, that installs a remote access trojan (OSV MAL-2026-2307, GitHub advisory GHSA-fw8c-xr5c-95f9). npm has since removed both versions, but a lockfile or cache may still hold them. If npm ls axios shows either, treat the machine as compromised, rotate its secrets from another machine and reinstall from a clean lockfile. Pin an exact version in production and review lockfile changes for axios.
Basic requests
import axios from 'axios'
const { data, status } = await axios.get('https://api.github.com/repos/axios/axios', {
params: { per_page: 5 }, // becomes ?per_page=5
headers: { Accept: 'application/vnd.github+json' },
})
const created = await axios.post('https://api.example-shop.dev/orders', {
sku: 'KB-104',
qty: 2,
}) // objects are sent as JSON
Method helpers: get, delete, head, options take (url, config); post, put, patch take (url, data, config). axios.request(config) takes everything in one object. response has data, status, statusText, headers, config, request.
Instances
Create one instance per upstream API and put shared settings on it.
export const billing = axios.create({
baseURL: 'https://billing.internal.corp.example/v2',
timeout: 5000, // ms, whole request
headers: { 'X-Client': 'invoice-worker' },
maxContentLength: 10 * 1024 * 1024, // bytes; default is unlimited
maxBodyLength: 10 * 1024 * 1024,
})
Set maxContentLength and maxBodyLength when the other side is not fully trusted: both default to unlimited, so a hostile server can return a small compressed body that expands to gigabytes.
Interceptors
billing.interceptors.request.use(config => {
config.headers.set('Authorization', `Bearer ${process.env.BILLING_API_TOKEN}`)
return config
})
// retry 503 responses up to 3 times
billing.interceptors.response.use(undefined, async error => {
const config = error.config
if (error.response?.status === 503 && (config.retryCount = (config.retryCount ?? 0) + 1) <= 3) {
await new Promise(resolve => setTimeout(resolve, 200 * config.retryCount))
return billing(config)
}
throw error
})
Use config.headers.set(...) inside interceptors. Always rethrow (or return a rejected promise) when you do not handle the error. For anything beyond simple retries, add a retry library rather than growing the interceptor.
Errors
Axios throws AxiosError for network failures, timeouts, cancellation and non-2xx responses (control the last with validateStatus).
import axios, { isAxiosError } from 'axios'
try {
await billing.get('/invoices/INV-1042')
} catch (error) {
if (isAxiosError(error)) {
if (error.response) {
// server answered with a non-2xx status
console.error(error.response.status, error.response.data)
} else if (error.code === 'ECONNABORTED') {
console.error('timed out')
} else if (axios.isCancel(error)) {
console.error('cancelled')
} else {
console.error('no response', error.code) // e.g. ECONNREFUSED, ENOTFOUND
}
} else {
throw error
}
}
error.code is ERR_BAD_REQUEST for 4xx, ERR_BAD_RESPONSE for 5xx, ECONNABORTED for a timeout and ERR_CANCELED for a cancelled request. To treat 404 as a normal result, pass validateStatus: status => status < 500.
Timeouts and cancellation
// per-request timeout
await billing.get('/reports/monthly', { timeout: 30_000 })
// cancel with AbortController
const controller = new AbortController()
const pending = billing.get('/reports/monthly', { signal: controller.signal })
controller.abort() // pending rejects with ERR_CANCELED
// cancel after a deadline
await billing.get('/reports/monthly', { signal: AbortSigna
Install axios in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
FAQ
What does the axios skill do?
Axios is a promise-based HTTP client for Node.js and browsers that sends requests, parses JSON, and rejects on error status codes. Use it when asked to "call a REST API from Node", "add a base URL and auth header to every request", "retry on 503", "cancel a request", "set a timeout", "handle axios errors", or "upgrade axios because of a security advisory". Covers instances, interceptors, AbortController cancellation, timeouts, error handling, the fetch adapter, size limits, and which versions to avoid.
How do I install the axios skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the axios skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
by Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
by Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
by Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
by Anthropic