# axios
[![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://github.com/axios/axios/actions/workflows/ci.yml/badge.svg)
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](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://packagephobia.now.sh/badge?p=axios)](https://packagephobia.now.sh/result?p=axios)
[![npm downloads](https://img.shields.io/npm/dm/axios.svg?style=flat-square)](http://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)
Promise based HTTP client for the browser and node.js
> New axios docs website: [click here](https://axios-http.com/)
## Table of Contents
- [Features](#features)
- [Browser Support](#browser-support)
- [Installing](#installing)
- [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)
- [Browser](#browser)
- [Node.js](#nodejs)
- [Query string](#query-string)
- [Form data](#form-data)
- [Automatic serialization](#-automatic-serialization)
- [Manual FormData passing](#manual-formdata-passing)
- [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](http://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 data
- Client side support for protecting against [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery)
## Browser Support
![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/src/safari/safari_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Edge](https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![IE](https://raw.github.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
Using npm:
```bash
$ npm install axios
```
Using bower:
```bash
$ bower install axios
```
Using yarn:
```bash
$ yarn add axios
```
Using jsDelivr CDN:
```html
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
```
Using unpkg CDN:
```html
<script src="https://unpkg.com/axios/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
const axios = require('axios').default;
// axios.<method> will now provide autocomplete and parameter typings
```
Performing a `GET` request
```js
const axios = require('axios').default;
// 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);
})
.then(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);
})
.then(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 (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
```
Performing multiple concurrent requests
```js
function getUserAccount() {
return axios.get('/user/12345');
}
function getUserPermissions() {
return axios.get('/user/12345/permissions');
}
Promise.all([getUserAccount(), getUserPermissions()])
.then(function (results) {
const acct = results[0];
const perm = results[1];
});
```
## axios API
Requests can be made by passing the relevant config to `axios`.
##### axios(config)
```js
// Send a POST request
axios({
method: 'post',
url: '/user/12345',
data: {
firstName: 'Fred',
lastName: 'Flintstone'
}
});
```
```js
// GET request for remote image in node.js
axios({
method: 'get',
url: 'http://bit.ly/2mTM3nY',
responseType: 'stream'
})
.then(function (response) {
response.data.pipe(fs.createWriteStream('ada_lovelace.jpg'))
});
```
##### axios(url[, config])
```js
// Send a GET request (default method)
axios('/user/12345');
```
### Request method aliases
For convenience, aliases have been provided for all common request methods.
##### axios.request(config)
##### axios.get(url[, config])
##### axios.delete(url[, config])
##### axios.head(url[, config])
##### axios.options(url[, config])
##### axios.post(url[, data[, config]])
##### axios.put(url[, data[, config]])
##### axios.patch(url[, data[, config]])
###### NOTE
When using the alias methods `url`, `method`, and `data` properties don't need to be specified in config.
### Concurrency (Deprecated)
Please use `Promise.all` to replace the below functions.
Helper functions for dealing with concurrent requests.
axios.all(iterable)
axios.spread(callback)
### Creating an instance
You can create a new instance of axios with a custom config.
##### axios.create([config])
```js
const instance = axios.create({
baseURL: 'https://some-domain.com/api/',
timeout: 1000,
headers: {'X-Custom-Header': 'foobar'}
});
```
### Instance methods
The available instance methods are listed below. The specified confi
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Vue+Echarts监控大屏实例九:智慧园区监控模板实例,包括源码,开发文档、素材等。 使用vue-echarts实现监控大屏搭建,开发,实现对于监控界面的相关开发资料,提供实例源码、开发过程视频及实现过程。 高德地图并展示对于报表,界面尺寸进行调整使用vh及rem设置对应尺寸以便自适应,代码使用vue3写法,整体框架进行调整,使用steup语法糖,数据使用响应式写法等。 使用HBuilderX开发,提供开发过程视频、相关文档、源码素材等。 智慧园区数据可视化监控大屏,echarts报表实现,智慧园区监控大屏。
资源推荐
资源详情
资源评论
收起资源包目录
Vue+Echarts监控大屏实例九:智慧园区监控模板实例 (16453个子文件)
cssesc.1 2KB
openChrome.applescript 2KB
README.md.bak 12KB
index.cjs 169KB
index.cjs 53KB
index.cjs 40KB
floating-ui.core.cjs 33KB
floating-ui.dom.cjs 19KB
index.browser.cjs 4KB
index.cjs 3KB
index.cjs 3KB
index.browser.cjs 3KB
index.cjs 2KB
index.cjs 854B
index.cjs 697B
index.cjs 559B
index.cjs 559B
index.cjs 247B
nanoid.cjs 91B
metadata.cjs 45B
require.cjs 35B
parser.cmd 293B
vue-demi-switch.cmd 291B
vue-demi-fix.cmd 288B
rollup.cmd 282B
nanoid.cmd 281B
esbuild.cmd 279B
cssesc.cmd 277B
json5.cmd 276B
vite.cmd 276B
cup.coffee 1B
mug.coffee 0B
index.css 300KB
index.css 300KB
el-col.css 32KB
el-date-picker.css 23KB
swiper.css 20KB
swiper.min.css 17KB
el-table.css 16KB
el-tabs.css 15KB
el-time-picker.css 13KB
el-time-select.css 12KB
el-input.css 12KB
el-button.css 12KB
el-upload.css 11KB
el-select-v2.css 10KB
el-menu.css 9KB
el-select.css 8KB
el-pagination.css 8KB
base.css 8KB
el-color-picker.css 6KB
el-tag.css 6KB
el-checkbox.css 6KB
el-cascader.css 5KB
el-message-box.css 5KB
el-var.css 5KB
el-tree.css 5KB
el-transfer.css 4KB
el-step.css 4KB
el-collapse.css 4KB
el-switch.css 4KB
el-radio.css 4KB
el-table-v2.css 4KB
el-slider.css 4KB
el-dropdown.css 4KB
el-input-number.css 4KB
default.css 3KB
el-form.css 3KB
el-dialog.css 3KB
el-select-dropdown.css 3KB
el-button-group.css 3KB
el-carousel.css 3KB
el-link.css 3KB
el-notification.css 3KB
el-tooltip-v2.css 3KB
el-radio-button.css 3KB
el-alert.css 3KB
dark_theme.css 3KB
css-vars.css 3KB
el-message.css 3KB
el-checkbox-button.css 3KB
el-cascader-panel.css 3KB
el-descriptions.css 2KB
el-popper.css 2KB
el-drawer.css 2KB
el-autocomplete.css 2KB
el-progress.css 2KB
el-image-viewer.css 2KB
el-timeline-item.css 2KB
el-loading.css 2KB
el-calendar.css 2KB
el-result.css 1KB
el-table-column.css 1KB
el-scrollbar.css 1KB
el-rate.css 1KB
el-option-item.css 1KB
el-reset.css 1KB
el-empty.css 1KB
el-badge.css 1KB
el-popover.css 1KB
共 16453 条
- 1
- 2
- 3
- 4
- 5
- 6
- 165
军军君01
- 粉丝: 2w+
- 资源: 31
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- SSC338D/SSC338Q系列4k/20fps,高性能MJPEG/H.264/H.265视频编码器
- 2011-2022年各省粮食波动率测算数据(含原始数据+计算说明+结果).xlsx
- 基于FPGA(Verilog)编写DAC7568-8168-8568芯片驱动
- spring知识点总结(spring和springMVC)
- MRT.EXE微软的清理工具
- 十八届全国大学生智能汽车竞赛-室外赛规则简介.pdf
- 迁移学习 inception-v3, 搭建基于微信小程序的前端识别程序 .zip(毕设&课设&实训&大作业&竞赛&项目)
- Python课程设计任务书pdf
- 基于OpenCV、YOLO和Vibe的,用于视频监控下的行人流量统计系统 .zip(毕设&课设&实训&大作业&竞赛&项目)
- 基于FPGA的ADC7606B驱动
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页