Closed KB1RD closed 7 months ago
Note: Putting const user = useDirectusUser();
in the async function before calling getItemById
also does not work.
Hi @KB1RD, have you tried accessing the user's attributes via user.value
(according to this sample)?
My apologies; I used Vue years ago, and have been trying to familiarize myself with Vue 3. Seems I need to go through the whole docs and re-learn from scratch as there are so many "gotchas" for someone familiar with old versions of Vue.
Version
nuxt-directus
^5.6.1
nuxt:^3.11.1
Reproduction Link
I cannot share my entire codebase at this time; Below is the segment of code causing the issue:
Steps to reproduce
Owner
) in this content to the current user's ID using various methods (see the code sample above). Note that in my case, thisgetItemById
function actually will fail with HTTP 403 if the user is not signed in, so in this function call, the user ID must be known somewhere innuxt-directus
.What is Expected?
At the very least, the print statement labelled
COMPUTE1
should print out both user ids, instead ofundefined
foruser.id
. It is definitely accessible in that code block, since the above statement relies on having the user currently signed in.What is actually happening?
In all of the above examples,
user.id
evaluates toundefined
. What is especially weird is that the print statement labeled "User:" prints the following:So Nuxt knows about the user object, knows its ID, but doesn't want to share. The workaround that I am currently using is:
...to obtain the user object. But this is not a long-term solution.