How to export the value of the callback function in async

  // token
  async getLocalAccessToken() {
    const token = await fs.readFile("wechatToken. txt", "utf8", (err, data) => {
      return token;
    });
    return token;
  }
  // accesstoken
  async updateMenu() {
    // const access_token = await this.ctx.service.home.getLocalAccessToken();
  }

I want to call getLocalAccessToken in the updateMenu function to get the value of token. I know it is wrong to write this way. If I call it asynchronously, I will execute return token; first. How do I write it?

May.23,2022

 getLocalAccessToken() {
    return new  Promise((resolve,reject)=>{
        fs.readFile('wechatToken.txt','utf8',(e,data)=>e?reject(e):resolve(data));
    });
  }

caller

const access_token = await this.ctx.service.home.getLocalAccessToken();

needs to return a Promise

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3047f-2bce4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3047f-2bce4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?