I am trying to send post request to an external api in aws lambda using nodejs 10.x. But I am getting errorResponse: { "errorMessage": "Converting circular structure to JSON", "errorType": "TypeError", "stackTrace": [] } Please find the code below:const http = require('https'); exports.handler = async (event) => { return new Promise((resolve, reject) => { const req = http.request('https://jsonplaceholder.typicode.com/posts', (res) => { resolve(res); }); req.on('error', (e) => { reject({error: e.message}); }); // send the request req.write(''); req.end(); }); }; I am expecting json response like below[ { "userId": 1, "id": 1, "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit", "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto" }, { "userId": 1, "id": 2, "title": "qui est esse", "body": "est rerum tempore vitae\nsequi sint nihil reprehenderit dolor beatae ea dolores neque\nfugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis\nqui aperiam non debitis possimus qui neque nisi nulla" } ]
Submitted September 15, 2019 at 04:59PM by vijhhh2
No comments:
Post a Comment