等待功能条件无法正常工作

时间:2019-11-04 19:45:57

标签: javascript async-await apollo-client

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

0 个答案:

没有答案