云函数中怎么获取accesstoken值呢
发布于 6 年前 作者 xiongxiuying 2198 次浏览 来自 问答

说简单点就是责怎么在云函数中发送请求出去呢,我用了request,好像请求没发出去。

日志能看到的

2 回复

请求还没开始就 就结束了

给个粟子你抄吧

//npm install  request-promise

const rp = require(‘request-promise’);

// 云函数入口函数

exports.main = async(event, context) => {

var res = await rp(

{

method: ‘get’,

uri: ‘https:/xxxx.com’,

qs: {

},//参数

headers: {},//请求头

json: true  //是否json数据

}

).then((  body) => {

return body

}).catch(err => {

return err;

})

return res;

}

解决了,非常感谢!

回到顶部