Skip to content
Discussion options

You must be logged in to vote

Upon more testing I found that I needed to wait for my useUser() function result to be returned, so I had to also use useLazyQuery to execute my query later when user is fully loaded.

const [getBeers, { loading, data, error }] = useLazyQuery(GET_BEERS, {
    variables: getVariables(router.query.index),
    context: {
      headers: {
        Authorization: user?.jwt ? `Bearer ${user.jwt}` : "",
      },
    },
  });

  useEffect(() => {
    if (user) {
      getBeers();
    }
  }, [user]);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Dannymx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant