云函数中怎么获取accesstoken值呢

发布于 8 年前作者 xiongxiuying2311 次浏览最后编辑 8 年前来自 ask

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

日志能看到的

2 回复
ping52
ping521 楼6 年前

请求还没开始就 就结束了

给个粟子你抄吧

//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;

}

aguo
aguo2 楼6 年前

解决了,非常感谢!