Util.promisify

Hey does anyone know why my code below doesn’t return answer to the user parameter, in my then() statement. It only runs through getUser and never follows onto the .then() or .catch(). I’ve console logged and answer is defined appropriately.

Also what is the point or difference with util.promisify, as opposed to creating the promise with async/await? Is it just the original way in which node integrated a method for a promise and we’re learning legacy code or is there a specific difference that i’m missing?

Here’s my code:

const util = require('util') const getUser = (id) => { return setTimeout(() => { const answer = (id === 1)?'dave':new Error('user not found'); console.log(answer) return answer }, 2000) }; const getUserPromise = util.promisify(getUser); getUserPromise(1) .then((user) => { console.log(`user ${user} has been found`) }) .catch((error) => { console.log('error state ', error) })