I am using the HTTPS npm package. How to return the response from the backend to the frontend.
export function pay(checksum, Host, ID){
Params.head = {
"signature": checksum
};
var post_data = JSON.stringify(Params);
var options = {
hostname: Host,
port: 443,
path: `/initTrans?mid=${mid}&Id=${ID}`,
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': post_data.length,
'Accept': 'application/json'
}
};
var response = "";
var post_req = https.request(options, function (post_res) {
post_res.on('data', function (chunk) {
response += chunk;
});
return post_res.on('end', async function () {
return response
});
});
post_req.write(post_data);
post_req.end()
}