It's hard to tell what's happening if we can't see what fn1 is or does. But get_data needs to return a promise, not the value there. In fact, that return statement isn't the return statement for get_data, it is the return statement for the unnamed ES6 Arrow Function, which returns res to the promise just to get passed to the next .then() function. It doesn't get passed to get_data at all.
By immediately returning a new Promise, get_data waits until the promise finishes. And whatever calls get_data can call .then() to use that value.
Like this:
module.exports.get_data = function(input){
return new Promise((resolve,reject)=>{
var promise = fn1();
promise
.then((res) => {
// process res
resolve(res)
})
})
}
But all this seems redundant.
While I haven't used await in node, it should work the same as other languages. Which means you should be able to do the following
module.exports.get_data = async function(input){
var res = await fn1();
return res
}
Assuming fn1 is a promise...