新手入门 您所在的位置:网站首页 anxious名词是什么 新手入门

新手入门

2024-06-26 13:14| 来源: 网络整理| 查看: 265

新手入门

基于 Promise 的 HTTP 客户端,适用于浏览器和 node.js

什么是 Axios?

¥What is Axios?

Axios 是一个 基于 promise 的 HTTP 客户端,适用于 node.js 和浏览器。它是 同构的(即它可以使用同一套代码运行在浏览器和 nodejs 中)。在服务器端它使用原生的 node.js http 模块,在客户端(浏览器)它使用 XMLHttpRequests。

¥Axios is a promise-based HTTP Client for node.js and the browser. It is isomorphic (= it can run in the browser and nodejs with the same codebase). On the server-side it uses the native node.js http module, while on the client (browser) it uses XMLHttpRequests.

特性

¥Features

从浏览器发出 XMLHttpRequests

¥Make XMLHttpRequests from the browser

从 node.js 发出 http 请求

¥Make http requests from node.js

支持 Promise API

¥Supports the Promise API

拦截请求和响应

¥Intercept request and response

转换请求和响应数据

¥Transform request and response data

取消请求

¥Cancel requests

超时

¥Timeouts

支持嵌套条目的查询参数序列化

¥Query parameters serialization with support for nested entries

自动请求主体序列化为:

¥Automatic request body serialization to:

JSON (application/json)

多部分/表单数据 (multipart/form-data)

¥Multipart / FormData (multipart/form-data)

URL 编码形式 (application/x-www-form-urlencoded)

¥URL encoded form (application/x-www-form-urlencoded)

将 HTML 表单作为 JSON 发送

¥Posting HTML forms as JSON

响应中的自动 JSON 数据处理

¥Automatic JSON data handling in response

浏览器和 node.js 的进度捕获,并提供额外的信息(速度、剩余时间)

¥Progress capturing for browsers and node.js with extra info (speed rate, remaining time)

为 node.js 设置带宽限制

¥Setting bandwidth limits for node.js

兼容符合规范的 FormData 和 Blob(包括 node.js)

¥Compatible with spec-compliant FormData and Blob (including node.js)

客户端支持防御 XSRF

¥Client side support for protecting against XSRF

安装

¥Installing

使用 npm:

¥Using npm:

$ npm install axios

使用 bower:

¥Using bower:

$ bower install axios

使用 yarn:

¥Using yarn:

$ yarn add axios

使用 jsDelivr CDN:

¥Using jsDelivr CDN:

使用 unpkg CDN:

¥Using unpkg CDN:

预构建的 CommonJS 模块用于使用 require 直接导入(如果你的模块打包器无法自动解析它们)

¥Prebuilt CommonJS modules for direct importing with require (if your module bundler failed to resolve them automatically)

const axios = require('axios/dist/browser/axios.cjs'); // browser const axios = require('axios/dist/node/axios.cjs'); // node 下一章 » 示例


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有