I have created a node.js application using promise. I have following code
async clientCall() {
const baseUrl = 'https://localhost:44300/test';
const queryString = '';
var options = {
uri: baseUrl + queryString,
};
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
var result = await request.get(options, function (err: any, res: any, body: any) {
console.log("Result: ", body)
return body;
})
console.log("response:",result);
// return result;
}
await ClientRepository.clientCall().then(data => {
console.log("inside data: ",data)
return data;
})
But i got output like this
response:
Result: My response
inside data: undefined
inside data: My response
I need to return response only after await request is completed.