Like Ha Ja said, I think you still need to resolve the promise. If you just return the await you're going to get a promise.
const fs = require ('fs')
function getText () {
return new Promise( (resolve, reject) => {
fs.readFile('./foo.txt', 'utf8', (err, data) => {
if (err) {
reject(err)
}
resolve(data)
})
})
}
async function output () {
try {
let result = await getText()
console.log("inside try: ", result)
return result
}
catch (err){
console.log(err)
}
}
console.log("outside: ", output())
output().then( result => console.log("after then: ", result))
// outside: Promise { <pending> }
// inside try: foo text
// inside try: foo text
// after then: foo text