I am working with express server and trying to read data from file and return it to different function.
My code structure looks like this:
async function getUser(req) { 
   fs.readFile(cfg.fileDefaults, (err, defaults) => {
      do something
      return user;
    }
}
module.exports = {getUser}
In controller I call that function
  static getTable(req, res, next) {
    async function search() {
      user = await  getUser(req);  //return undefined
     getUser(req).then((a) => {
           console.log(a);       //second try, return undefined
          })
    }
    search();
}
How should I call it correctly?
 
    