使异步函数返回Promise

问题描述

我有一个异步函数,我想返回一个承诺。如果我将其包装在一个Promise中,则表示异步函数中必须包含await之类的内容。

async function accessSpreadsheet(first_name,last_name,email,phone) {
  await doc.useServiceAccountAuth({
    client_email: creds.client_email,private_key: creds.private_key,});

  await doc.loadInfo(); // loads document properties and worksheets

  const sheet = doc.sheetsByIndex[0]; // or use doc.sheetsById[id]
  console.log(sheet.title);
  await sheet.addRow({ "first name": first_name,"last name": last_name,email: email,phone:phone });
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)