I have the program below:
const request = require('request');
var res = {};
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0
res = adpost();
//console.log(res.body);
console.log(res.body);
async function adpost() {
var postResponse = await Post();
return postResponse;
}
async function Post() {
const options = {
url: "xxx",
form: {
'usenumber': ''
}
};
return new Promise((resolve, reject) => {
request(options, (error, response, body) => {
if (error) {
return resolve({
body,
error
});
}
return resolve({
body,
response
})
});
})
}
As it returns the promise, I tried to call in another async function as well. I always get a pending promise or undefined
. How will I get the actual value?