微信小程序云函数请求api
作者:互联网
// 云函数入口文件 const cloud = require('wx-server-sdk') var req = require('request-promise'); cloud.init() // 云函数入口函数 exports.main = async (event, context) => { const {method,param1,param2} = event let url = 'http://ttttt.com'; let options = {}; if(method == 'post'){ options = { uri: url, method:"POST", headers: { 'User-Agent': 'Request-Promise' }, body: { param1:param1, param2:param2, }, json: true }; }else{ options = { uri: url, method:"GET", headers: { 'User-Agent': 'Request-Promise' }, qs: { param1:param1, param2:param2, }, json: true }; } return await req(options); }
标签:请求,url,微信,options,api,param2,param1,method,函数 来源: https://www.cnblogs.com/hhuiii/p/14313118.html