app.post('/getDetails', async function (req, res) {
var body
var post_req = await https.request(post_options, function (res) {
res.setEncoding('utf8');
body = '';
res.on('data', function (chunk) {
body += chunk;
console.log(body);
console.log(JSON.parse(body));
newBody = body;
}).on('error', function (error) {
console.log(error)
});
});
post_req.write(requestBody);
post_req.end();
res.send(body);
});
res.send(body) is sending undefined I have put a console.log(body) before res.send(body) it is showing undefined and inside variable post_req the body is having value