Slack API:如何使用 oAuth 进行身份验证?

问题描述

我正在关注Slack's docs on authenticating with oAuth.

范围和令牌设置得很好。我正在努力设置 installationStore.

这是我用来从 Firestore 数据库获取数据的代码

  installationStore: {
    fetchInstallation: async InstallQuery => {
      // change the line below so it fetches from your database
      // return await database.get(InstallQuery.teamId);

  let cityRef = db.collection("teams").doc(InstallQuery.teamId);
  let getDoc = cityRef
    .get()
    .then(doc => {
      if (!doc.exists) {
        console.log("No such document!");
      } else {
        console.log("Document data:",doc.data());
      }
    })
    .catch(err => {
      console.log("Error getting document",err);
    });

  return await getDoc;
}
}

我不确定我应该 return-await 是 getDoc,还是不是。有什么线索吗?

解决方法

尝试这样的事情:

installationStore: {
  fetchInstallation: async (InstallQuery) => {
    return await getData();
  };
}

async function getData() {
  try {
    let cityRef = db.collection("teams").doc(InstallQuery.teamId);
    let doc = await cityRef.get();
    return doc.data();
  } catch(ex){
      throw new Error("Failed fetching installation");
    }
}