const fs = require('fs')
const util = require('util')
const readFile = util.promisify(fs.readFile)
const buildMap = async () => {
let map = await readFile(process.argv[2], { encoding: 'utf-8' })
console.log(map) // Returns the right result
return map // Returns `Promise { <pending> }`
}
const game = buildMap()
console.log(game)
Why is it that in the code above, specifically
let map = await readFile(process.argv[2], { encoding: 'utf-8' })
console.log(map) // Returns the right result
return map // Returns Promise { <pending> }
that the return returns Promise pending, even though the line above it has the right result? And how could I change this so that it does?
Thanks in advance and sorry for the badly written question... (Writing well formulated SO questions is not one of my strong points)