Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

axios

БесплатноБез исполняемых скриптовНе проверен

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…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

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
Полный SKILL.md на GitHub

Установить axios в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл axios?

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.

Как установить скилл axios?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл axios запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить axios с