module.exports = (tel = '', body = '', from = {}, to = {}, callback) => {
var body = async function() {
return await makingAPICall();
};
console.log(body);
callback(null,[body].join('\n');
};
function makingAPICall() {
// Promise resolving stuff
}
The above code is in one of my files. Currently what is happening is that when I try to print out the variable body, I just get "async function() { \n return await makingAPICall();\n}", which is just the function body. I read some stuff on await and Promises but I am not sure if I am setting up the async function calls correctly. Any help will be appreciated. Thanks!
EDIT:
module.exports = (tel = '', body = '', from = {}, to = {}, callback) => {
var body = test();
console.log(body);
callback(null,[body].join('\n');
};
async function test() {
return await makingAPICall();
}
function makingAPICall() {
// Promise resolving stuff
}
I also tried doing this but this results in an Promise object being returned after calling test(). I am a bit confused on why this is happening even though I am using async functions and await.