我有以下lambda函数。我正在尝试发出GET请求并返回数据。我收到错误消息“将圆形结构转换为JSON”
有人知道我为什么会得到这个吗?
'use strict';
var http = require('https');
module.exports.hello = async (event, context) => {
return new Promise((resolve, reject) => {
const options = {
host: 'www.somehost.com',
path: '/somepath',
headers: {
'Authorization':'Bearer someBearerToken'
},
method: 'GET'
};
const req = http.request(options, (res) => {
console.log("success! data is: ", res)
resolve(res);
});
req.on('error', (e) => {
reject(e.message);
});
// send the request
req.write('');
req.end();
});
答案 0 :(得分:0)
删除行
console.log("success! data is: ", res)
res
是一个引用其自身的javascript对象。像
console.log("success! data is: ", res.data)