首页 > 解决方案 > 等待功能条件无法正常工作

问题描述

我试图在用户 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;
}

标签: javascriptasync-awaitapollo-client

解决方案


推荐阅读