<h1 align="center">
<b>
<a href="https://axios-http.com"><img src="https://axios-http.com/assets/logo.svg" /></a><br>
</b>
</h1>
<p align="center">Promise based HTTP client for the browser and node.js</p>
<p align="center">
<a href="https://axios-http.com/"><b>Website</b></a> â¢
<a href="https://axios-http.com/docs/intro"><b>Documentation</b></a>
</p>
<div align="center">
[![npm version](https://img.shields.io/npm/v/axios.svg?style=flat-square)](https://www.npmjs.org/package/axios)
[![CDNJS](https://img.shields.io/cdnjs/v/axios.svg?style=flat-square)](https://cdnjs.com/libraries/axios)
[![Build status](https://img.shields.io/github/actions/workflow/status/axios/axios/ci.yml?branch=v1.x&label=CI&logo=github&style=flat-square)](https://github.com/axios/axios/actions/workflows/ci.yml)
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod&style=flat-square)](https://gitpod.io/#https://github.com/axios/axios)
[![code coverage](https://img.shields.io/coveralls/mzabriskie/axios.svg?style=flat-square)](https://coveralls.io/r/mzabriskie/axios)
[![install size](https://img.shields.io/badge/dynamic/json?url=https://packagephobia.com/v2/api.json?p=axios&query=$.install.pretty&label=install%20size&style=flat-square)](https://packagephobia.now.sh/result?p=axios)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/axios?style=flat-square)](https://bundlephobia.com/package/axios@latest)
[![npm downloads](https://img.shields.io/npm/dm/axios.svg?style=flat-square)](https://npm-stat.com/charts.html?package=axios)
[![gitter chat](https://img.shields.io/gitter/room/mzabriskie/axios.svg?style=flat-square)](https://gitter.im/mzabriskie/axios)
[![code helpers](https://www.codetriage.com/axios/axios/badges/users.svg)](https://www.codetriage.com/axios/axios)
[![Known Vulnerabilities](https://snyk.io/test/npm/axios/badge.svg)](https://snyk.io/test/npm/axios)
</div>
## Table of Contents
- [Features](#features)
- [Browser Support](#browser-support)
- [Installing](#installing)
- [Package manager](#package-manager)
- [CDN](#cdn)
- [Example](#example)
- [Axios API](#axios-api)
- [Request method aliases](#request-method-aliases)
- [Concurrency ð](#concurrency-deprecated)
- [Creating an instance](#creating-an-instance)
- [Instance methods](#instance-methods)
- [Request Config](#request-config)
- [Response Schema](#response-schema)
- [Config Defaults](#config-defaults)
- [Global axios defaults](#global-axios-defaults)
- [Custom instance defaults](#custom-instance-defaults)
- [Config order of precedence](#config-order-of-precedence)
- [Interceptors](#interceptors)
- [Multiple Interceptors](#multiple-interceptors)
- [Handling Errors](#handling-errors)
- [Cancellation](#cancellation)
- [AbortController](#abortcontroller)
- [CancelToken ð](#canceltoken-deprecated)
- [Using application/x-www-form-urlencoded format](#using-applicationx-www-form-urlencoded-format)
- [URLSearchParams](#urlsearchparams)
- [Query string](#query-string-older-browsers)
- [ð Automatic serialization](#-automatic-serialization-to-urlsearchparams)
- [Using multipart/form-data format](#using-multipartform-data-format)
- [FormData](#formdata)
- [ð Automatic serialization](#-automatic-serialization-to-formdata)
- [Files Posting](#files-posting)
- [HTML Form Posting](#-html-form-posting-browser)
- [ð Progress capturing](#-progress-capturing)
- [ð Rate limiting](#-progress-capturing)
- [Semver](#semver)
- [Promises](#promises)
- [TypeScript](#typescript)
- [Resources](#resources)
- [Credits](#credits)
- [License](#license)
## Features
- Make [XMLHttpRequests](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) from the browser
- Make [http](https://nodejs.org/api/http.html) requests from node.js
- Supports the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) API
- Intercept request and response
- Transform request and response data
- Cancel requests
- Automatic transforms for [JSON](https://www.json.org/json-en.html) data
- ð Automatic data object serialization to `multipart/form-data` and `x-www-form-urlencoded` body encodings
- Client side support for protecting against [XSRF](https://en.wikipedia.org/wiki/Cross-site_request_forgery)
## Browser Support
![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/main/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_48x48.png) | ![Safari](https://raw.githubusercontent.com/alrra/browser-logos/main/src/safari/safari_48x48.png) | ![Opera](https://raw.githubusercontent.com/alrra/browser-logos/main/src/opera/opera_48x48.png) | ![Edge](https://raw.githubusercontent.com/alrra/browser-logos/main/src/edge/edge_48x48.png) | ![IE](https://raw.githubusercontent.com/alrra/browser-logos/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png) |
--- | --- | --- | --- | --- | --- |
Latest â | Latest â | Latest â | Latest â | Latest â | 11 â |
[![Browser Matrix](https://saucelabs.com/open_sauce/build_matrix/axios.svg)](https://saucelabs.com/u/axios)
## Installing
### Package manager
Using npm:
```bash
$ npm install axios
```
Using bower:
```bash
$ bower install axios
```
Using yarn:
```bash
$ yarn add axios
```
Using pnpm:
```bash
$ pnpm add axios
```
Once the package is installed, you can import the library using `import` or `require` approach:
```js
import axios, {isCancel, AxiosError} from 'axios';
```
You can also use the default export, since the named export is just a re-export from the Axios factory:
```js
import axios from 'axios';
console.log(axios.isCancel('something'));
````
If you use `require` for importing, **only default export is available**:
```js
const axios = require('axios');
console.log(axios.isCancel('something'));
```
For cases where something went wrong when trying to import a module into a custom or legacy environment,
you can try importing the module package directly:
```js
const axios = require('axios/dist/browser/axios.cjs'); // browser commonJS bundle (ES2017)
// const axios = require('axios/dist/node/axios.cjs'); // node commonJS bundle (ES2017)
```
### CDN
Using jsDelivr CDN (ES5 UMD browser module):
```html
<script src="https://cdn.jsdelivr.net/npm/axios@1.1.2/dist/axios.min.js"></script>
```
Using unpkg CDN:
```html
<script src="https://unpkg.com/axios@1.1.2/dist/axios.min.js"></script>
```
## Example
> **Note** CommonJS usage
> In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with `require()`, use the following approach:
```js
import axios from 'axios';
//const axios = require('axios'); // legacy way
// Make a request for a user with a given ID
axios.get('/user?ID=12345')
.then(function (response) {
// handle success
console.log(response);
})
.catch(function (error) {
// handle error
console.log(error);
})
.finally(function () {
// always executed
});
// Optionally the request above could also be done as
axios.get('/user', {
params: {
ID: 12345
}
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
})
.finally(function () {
// always executed
});
// Want to use async/await? Add the `async` keyword to your outer function/method.
async function getUser() {
try {
const response = await axios.get('/user?ID=12345');
console.log(response);
} catch (error) {
console.error(error);
}
}
```
> **Note**: `async/await` is part of ECMAScript 2017 and is not supported in Internet
> Explorer and older browsers, so use with caution.
Performing a `POST` request
```js
axios.post('/user', {
firstName: 'Fred',
lastName: 'Flintstone'
})
.then(function (respons
没有合适的资源?快使用搜索试试~ 我知道了~
node-modules.rar
共2000个文件
js:1271个
vue:160个
ts:149个
需积分: 1 0 下载量 124 浏览量
2023-09-25
14:37:02
上传
评论
收藏 17.09MB RAR 举报
温馨提示
AI大模型
资源推荐
资源详情
资源评论
收起资源包目录
node-modules.rar (2000个子文件)
openChrome.applescript 3KB
.babelrc 457B
README.md.bak 12KB
axios.cjs 112KB
publicUtils.cjs 112KB
axios.cjs 81KB
index.cjs 77KB
index.cjs 1016B
index.cjs 111B
cup.coffee 1B
mug.coffee 0B
viewuiplus.css 363KB
index.d.cts 17KB
.editorconfig 605B
.editorconfig 465B
.editorconfig 441B
.editorconfig 243B
.editorconfig 94B
esbuild 8.21MB
esbuild 8.21MB
.eslintignore 56B
.eslintrc 2KB
.eslintrc 743B
.eslintrc 339B
index.js.flow 315KB
index.js.flow 3KB
popper.js.flow 3KB
.gitkeep 0B
index.html 7KB
detached.html 5KB
demo.html 4KB
perf.html 3KB
index.html 2KB
padding-fontsize.html 1KB
inline.html 1KB
contenteditable.html 824B
specrunner.html 767B
nested.html 737B
dropdown.html 708B
multiple.html 705B
editable.html 607B
non-editable.html 578B
browser.html 301B
countUp.js.iml 458B
dep-2faf2534.js 1.99MB
compiler-sfc.esm-browser.js 1.46MB
viewuiplus.min.esm.js 1.19MB
view-ui-plus.js 1.04MB
rollup.js 875KB
rollup.js 873KB
viewuiplus.min.js 693KB
compiler-sfc.cjs.js 611KB
index.js 475KB
vue.global.js 463KB
vue.esm-browser.js 435KB
rollup.browser.js 388KB
rollup.browser.js 387KB
dep-19c40c50.js 328KB
chunk-3YKYIJLK.js 323KB
vue.runtime.global.js 321KB
runtime-dom.global.js 320KB
vue.runtime.esm-browser.js 297KB
runtime-dom.esm-browser.js 297KB
runtime-core.esm-bundler.js 230KB
runtime-core.cjs.js 224KB
dep-fd803d77.js 220KB
server-renderer.esm-browser.js 216KB
runtime-core.cjs.prod.js 174KB
compiler-dom.global.js 168KB
compiler-core.cjs.js 160KB
compiler-core.cjs.prod.js 155KB
compiler-dom.esm-browser.js 154KB
compiler-core.esm-bundler.js 139KB
watch.js 135KB
vue.esm-browser.prod.js 131KB
vue.global.prod.js 128KB
index.js 118KB
axios.js 94KB
popper.js 87KB
popper.js 86KB
vue.runtime.esm-browser.prod.js 84KB
runtime-dom.esm-browser.prod.js 84KB
vue.runtime.global.prod.js 83KB
runtime-dom.global.prod.js 83KB
popper.js 83KB
axios.js 82KB
main.js 81KB
element-resize-detector.js 67KB
compiler-dom.cjs.js 65KB
compiler-dom.cjs.prod.js 63KB
server-renderer.esm-browser.prod.js 58KB
compiler-dom.esm-browser.prod.js 57KB
compiler-dom.global.prod.js 57KB
test.js 55KB
test.js 55KB
runtime-dom.esm-bundler.js 45KB
runtime-dom.cjs.js 43KB
source-map-consumer.js 41KB
compiler-ssr.cjs.js 40KB
element-resize-detector_test.js 40KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
大宝贱
- 粉丝: 453
- 资源: 498
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 用于操作 ESC,POS 打印机的 Python 库.zip
- 用于控制“Universal Robots”机器人的 Python 库.zip
- 用于控制 Broadlink RM2,3 (Pro) 遥控器、A1 传感器平台和 SP2,3 智能插头的 Python 模块.zip
- 用于接收和交互来自 Slack 的 RTM API 的事件的框架.zip
- 用于将日志发送到 LogDNA 的 Python 包.zip
- 用于将 Python 计算转换为渲染的乳胶的 Python 库 .zip
- 用于实现推荐系统的 Python 库.zip
- 用于实施无服务器最佳实践并提高开发人员速度的开发人员工具包 .zip
- 用于地理数据的 Python 工具.zip
- 全国大学生FPGA创新设计竞赛作品 泡罩包装药品质量在线检测平台.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功