alipay-mini-program-open-api-request-options
基于Easy Open Api服务器开发框架以及alipay-mini-program-request-options包的请求拓展
alipay-mini-program-request-options
网络请求基于支付宝小程序网络请求Api的二次封装
文件上传基于支付宝小程序文件上传Api的二次封装
NPM信息
使用
添加默认配置
const OpenApi = // 默认配置const defaultConfig = version: '1.0' app_key: 'test' format: 'json' app_secret: '123456' url: `请求链接URL`// 创建实例const openApiInstance = defaultConfig// 添加默认配置openApiInstance
网络请求
// 创建请求实例openApiInstance ;
Api
Name | Param name array | Param type array | Return |
---|---|---|---|
setUrl | [url] | [String] | this |
setName | [name] | [String] | this |
setMethod | [method] | [String] | this |
setHeaders | [headers] | [Object] | this |
setTimeout | [timeout] | [Integer] | this |
setData | [data] | [Object] | this |
request | [completeCallback] | [Function] | Promise |
文件上传
const FileTypes = ;// 目前支付宝只支持图片、视频、音频3种文件类型const IMAGE VIDEO AUDIO = FileTypes; openApiInstance ;
Api
Name | Param name array | Param type array | Return |
---|---|---|---|
setUrl | [url] | [String] | this |
setName | [name] | [String] | this |
setHeaders | [headers] | [Object] | this |
setFile | [filePath, fileName, fileType] | [String, String, String] | this |
setFilePath | [filePath] | [String] | this |
setFileName | [fileName] | [String] | this |
setFileType | [fileType] | [String] | this |
upload | [completeCallback] | [Function] | Promise |