Axios 正在参加 2021 年度 OSC 中国开源项目评选,请投票支持!
Axios 在 2021 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
2021 年度 OSC 中国开源项目评选 正在火热进行中,快来投票支持你喜欢的开源项目!
2021 年度 OSC 中国开源项目评选 >>> 中场回顾
Axios 获得 2021 年度 OSC 中国开源项目评选「最佳人气项目」 !
授权协议 MIT
操作系统 跨平台
软件类型 开源软件
开源组织
地区 不详
投 递 者
适用人群 未知
收录时间 2016-11-06

软件简介

Axios,基于 Promise 的 HTTP 客户端,可以工作于浏览器中,也可以在 node.js 中使用。

功能:

  • 从浏览器中创建 XMLHttpRequest

  • 从 node.js 中创建 http 请求

  • 支持 Promise API

  • 拦截请求和响应

  • 转换请求和响应数据

  • 取消请求

  • 自动转换 JSON 数据

  • 客户端支持防止 XSRF 攻击

示例代码:

执行一个 GET 请求

// Make a request for a user with a given ID
axios.get('/user?ID=12345')
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });
// 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);
  });

执行一个 POST 请求

axios.post('/user', {
    firstName: 'Fred',
    lastName: 'Flintstone'
  })
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });

执行多个并发请求

function getUserAccount() {
  return axios.get('/user/12345');
}
function getUserPermissions() {
  return axios.get('/user/12345/permissions');
}
axios.all([getUserAccount(), getUserPermissions()])
  .then(axios.spread(function (acct, perms) {
    // Both requests are now complete
  }));
展开阅读全文

代码

的 Gitee 指数为
超过 的项目

评论

点击加入讨论🔥(2)
发表了资讯
2022/10/08 08:59

HTTP 库 Axios 推送损坏的更新,导致数千个网站瘫痪

Axios 是基于 Promise 的 HTTP 网络请求库,用于浏览器和 Node.js。Axios 体积非常小,提供了一个简单易用的库,具有易于扩展的接口。 近日 Axios 发布的 1.1.0 版本更新在推送给用户后,由于包含损坏,导致数千个网站瘫痪。 根据用户提交的 issue,在 Axios v1.1.0 中,他们使用axios.get时出现了错误,会提示 TypeError: axios.get is not a function。这导致几乎所有请求都无法成功,因为如果按照预期的行为,axios.get是一个...

25
3
发表了资讯
2017/11/12 07:48

Axios 0.17.1 发布,基于 Promise 的 HTTP 客户端

Axios 0.17.1 已发布,Axios 是基于 Promise 的 HTTP 客户端,可以用于浏览器中,也可以在 node.js 中使用。 更新内容: 修复用户提交的一项错误 (#1160) 允许 overriding transport (#1080) 更新 TypeScript typings (#1165, #1125, #1131) 下载地址: Source code (zip) Source code (tar.gz)...

2
10
发表了资讯
2017/10/24 07:46

Axios 0.17.0 发布,基于 Promise 的 HTTP 客户端

Axios 0.17.0 已发布,Axios 是基于 Promise 的 HTTP 客户端,可以用于浏览器中,也可以在 node.js 中使用。 更新内容: BREAKING 解决 baseURL 和拦截器的问题 (#950) BREAKING 改进对重复标题的处理 (#874) 支持禁用代理 (#691) 使用通用类型参数更新 TypeScript typings (#1061) 详情可查阅更新日志 下载地址: Source code (zip) Source code (tar.gz)...

4
15
没有更多内容
加载失败,请刷新页面
点击加载更多
加载中
下一页
发表了博客
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
发表了问答
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
暂无内容
2 评论
83 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部