javascript - 等待功能条件无法正常工作
问题描述
我试图在用户 Auth/UnAuth 情况下切换多个 Apollo 客户端。我所做的 ?
userCheck() 条件不能正常工作?
async function userCheck() {
return await Auth.currentAuthenticatedUser()
.then(() => {
return true;
})
.catch(() => {
return false;
});
}
function createApolloClient(initialState) {
const client = functionFirst();
const clientPublic = functionSecond();
if (userCheck()) {
return client;
}
return clientPublic;
}
解决方案
推荐阅读
- android - 任务 ':app:mergeDebugResources' parseError 执行失败
- r - 使用 kde2d 在核密度估计中找到区域的概率
- mysql - 操作复杂搜索的 Doctrine JSON 函数
- sql-server - 根据值更改选择具有最近两个日期的行
- html - 为什么 CSS 没有应用在我使用 Angular Materials Side Nav Bar 的 Angular 项目中?
- python - 为什么无论我的分数是多少,我都会收到相同的输出?
- python - 为什么 Django-atom 包在我的 atom 编辑器中不起作用?
- android - 为什么电容在android app上显示小屏幕
- unreal-engine4 - 当我操纵(旋转,缩放)3d 网格时,虚幻引擎 4.22.3 崩溃
- ios - 从图像中捕获文本 - SwiftUI