0.1.0 • Published 1 year ago
ivy-mp-fetch v0.1.0
ivy-mp-fetch
浏览器里可以用 window.fetch
,node 中可以用 node-fetch
,小程序中就用 ivy-mp-fetch
吧!
原生主要支持的小程序有,并且主要支持处理 text 和 json 两种返回值,其它返回值没验证过,请谨慎使用
- 微信 wx https://developers.weixin.qq.com/miniprogram/dev/api/network/request/wx.request.html
- 支付宝 my https://opendocs.alipay.com/mini/api/owycmh
另外,可以非常方便的快速扩展其它小程序,参考下面文档
- 钉钉 dd https://open.dingtalk.com/document/orgapp-client/send-network-requests
- 百度 swan https://smartprogram.baidu.com/docs/develop/api/net/request/
- 抖音 tt https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/api/network/http/tt-request/
- 京东 jd https://mp-docs.jd.com/api/network/request.html
使用
import fetch from 'ivy-mp-fetch'
fetch(url, {
method: 'GET',
headers: {},
platforms: {
// 配置其它小程序平台请求库
},
//...
}).then(res => {
if (res.status === 200) {
return res.json()
}
})
0.1.0
1 year ago