Reputation: 193
I've got the following lambda function. I'm trying to make a GET request and return the data. I'm getting the error "Converting circular structure to JSON"
Does anyone know why I might be getting this?
'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();
});
Upvotes: 1
Views: 2471
Reputation: 10083
Remove the line
console.log("success! data is: ", res)
res
is a javascript object with reference to its own. Print the specific data you wish to inspect like
console.log("success! data is: ", res.data)
Upvotes: 2