
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
@twaves/axios-miniprogram-adapter
Advanced tools
axios的小程序适配器,支持在各个平台小程序中使用axios.
Taro 适配器请点击这里
微信小程序
|
支付宝小程序
|
钉钉小程序
|
百度小程序
|
.
├── demo 使用demo
├── dist 编译产出代码
├── doc 项目文档
├── src 源代码目录
├── test 单元测试
├── CHANGELOG.md 变更日志
└── TODO.md 计划功能
通过npm下载安装代码
$ npm i axios axios-miniprogram-adapter
import axios from 'axios'
import mpAdapter from 'axios-miniprogram-adapter'
axios.defaults.adapter = mpAdapter
// or with extra config transformer
axios.defaults.adapter = config => mpAdapter(config, { transformRequestOption: requestOption => { /* modify requestOption here */ return requestOption } })
直接使用小程序开发工具自带的构建npm,请按下面几个步骤引入:
$ npm init
$ npm i axios axios-miniprogram-adapter
在小程序开发者工具中依次找到并点击工具->构建npm,构建完成后你的项目目录会多出一个miniprogram_npm目录
代码引入使用
import axios from 'axios'
import mpAdapter from 'axios-miniprogram-adapter'
axios.defaults.adapter = mpAdapter
这里有一个代码片段demo可直接供你使用:https://developers.weixin.qq.com/s/oIqQtBml7F4N,DEMO源码点这里也可查看
直接拷贝编译后的axios、axios-miniprogram-adapter到项目中:
import axios from '你的目录/axios.js'
import mpAdapter from '你的目录/axios-miniprogram-adapter.js'
axios.defaults.adapter = mpAdapter
小程序自带的npm不支持解析node_modules中的库再有外部依赖:例如本库中依赖了axios库的某些工具包,在源码中有下面的代码:
import utils from 'axios/lib/utils'
在小程序开发工具中会报错,找不到此依赖。为此,我将依赖打包到一起,这样带来的问题是库的体积多了2kb,基于此,强烈推荐你使用类似于webpack的脚手架工具开发
打开小程序开发者工具,根据不同平台,选择各自的目录作为项目根目录:
axios-miniprogram-adapter/demo/miniprograme-example/dist-wechataxios-miniprogram-adapter/demo/miniprograme-example/dist-alipayaxios-miniprogram-adapter/demo/miniprograme-example/dist-swan该demo示范了几个常用功能的用法:
FAQs
Axios adapter for miniprogram
We found that @twaves/axios-miniprogram-adapter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.