{"id":41719316,"url":"https://github.com/xz-77/axios-adapter-miniprogram","last_synced_at":"2026-01-24T22:28:28.810Z","repository":{"id":57700726,"uuid":"479213936","full_name":"xz-77/axios-adapter-miniprogram","owner":"xz-77","description":"基于Axios扩展小程序网络请求库","archived":false,"fork":false,"pushed_at":"2022-06-17T10:27:53.000Z","size":419,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-29T05:43:12.786Z","etag":null,"topics":["axios","miniprogram","network","wechat"],"latest_commit_sha":null,"homepage":"https://xz-77.github.io/axios-adapter-miniprogram","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xz-77.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-08T02:14:44.000Z","updated_at":"2022-06-17T09:46:11.000Z","dependencies_parsed_at":"2022-09-26T21:11:52.154Z","dependency_job_id":null,"html_url":"https://github.com/xz-77/axios-adapter-miniprogram","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/xz-77/axios-adapter-miniprogram","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xz-77%2Faxios-adapter-miniprogram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xz-77%2Faxios-adapter-miniprogram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xz-77%2Faxios-adapter-miniprogram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xz-77%2Faxios-adapter-miniprogram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xz-77","download_url":"https://codeload.github.com/xz-77/axios-adapter-miniprogram/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xz-77%2Faxios-adapter-miniprogram/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28738856,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T22:12:27.248Z","status":"ssl_error","status_checked_at":"2026-01-24T22:12:10.529Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["axios","miniprogram","network","wechat"],"created_at":"2026-01-24T22:28:28.136Z","updated_at":"2026-01-24T22:28:28.800Z","avatar_url":"https://github.com/xz-77.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# axios-adapter-miniprogram\n\n## 使用方式\n### axios-adapter-wechat\n\n根据`Axios`适配了微信小程序`wx.request`没有进行环境的判断\n\n```bash\n$ yarn add axios-adapter-wechat\n# or\n$ npm install axios-adapter-wechat --save-dev\n```\n\n```javascript\n\n// 判断小程序环境\n\nimport axios, { AxiosAdapter } from 'axios';\nimport wechatAdapter from 'axios-adapter-wechat';\nif (typeof wx !== 'undefined' \u0026\u0026 !!wx?.request \u0026\u0026 Object.prototype.toString.call(wx?.request) === '[object Function]') {\n  // 用来判断是否小程序环境 默认 timeout = 15s\n  axios.defaults.adapter = wechatAdapter as AxiosAdapter;\n}\n```\n\n### axios-adapter-miniprogram\n\n根据`axios-adapter-wechat`集成了微信小程序环境判断，直接引用即可，其他的与`Axios`保持一致\n\n```bash\n$ yarn add axios-adapter-miniprogram\n# or\n$ npm install axios-adapter-miniprogram --save-dev\n```\n\n\n```javascript\nimport axios from 'axios-adapter-miniprogram';\n```\n\n## 为什么要写这个库\n\n- 现在小程序的开发越来越多，每个小程序在网络请求方面都有官方自己的实现，但是不论在请求参数还是返回属性甚至使用习惯上，都不是很统一\n- 希望和 H5、PC、Node 等不同客户端上进行对齐\n- 相对来说有稍微看过 [Axios](https://www.axios-http.cn/docs/intro) 的源码，而且 [Axios](https://www.axios-http.cn/docs/intro) 的每周[下载量](https://www.npmjs.com/package/axios)在几千万的数量级，如果和 axios 对齐，大家都比较熟悉，好上手\n- 希望通过这个库来让开发人员不论从使用习惯，api 调用都和其他端对齐，在网络请求这个节点上抹平不同端所带来的影响\n\n## 解决方案\n\n1. 使用 Axios 并扩展 Axios 的 adapter 方法\n2. [Axios](https://www.axios-http.cn/docs/intro)\n\n## 新手上路\n\n1. 基于 `Axios` 的 `adapter` 方法兼容原生 `wx` 小程序网络请求(没有使用除 `axios` 以外第三方包)\n2. 兼容网络请求 `API` 与 `Axios` 一致，具体调用文档看[Axios 官网](https://www.axios-http.cn/docs/intro)\n3. 返回字段与 `Axios` 保持一致，这里没有使用 `wx` 小程序返回的原生字段，方便后续其他端网络请求的扩展\n4. 目前仅扩展 `wx` 小程序网路请求\n\n## 于 axios 不同的地方\n\n- 微信的 form 表单提交[使用 wx.request 发送 multipart/form-data 请求的方法](https://developers.weixin.qq.com/community/develop/article/doc/0000cc0e5bc5d093c6f8be17254c13)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxz-77%2Faxios-adapter-miniprogram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxz-77%2Faxios-adapter-miniprogram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxz-77%2Faxios-adapter-miniprogram/lists"}