问题描述
我正在关注Slack's docs on authenticating with oAuth.
范围和令牌设置得很好。我正在努力设置 installationStore.
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");
}
}