Can't get users in Convex functions
Hey guys, I'm trying to add more fields into my user object, but when I try to return I can't seem to get the data.
I followed the docs for working with users in Functions here: https://docs.convex.dev/auth/functions-auth
Attaching some screenshots:
16 Replies
my suspicion is that the user is not even stored as the users table is empty (I took the example from the docs)
yeah, users aren't being stored. definitely first step is making sure you're getting that table populated as verified in your dashboard
@rutenisraila make sure you're calling the store mutation from your app:
https://docs.convex.dev/auth/database-auth#calling-storeuser-from-react
Storing Users in the Convex Database | Convex Developer Hub
You might want to have a centralized place that stores information about the
I followed this guide down to the T and I still con't find any authenticated users in my database
@joe πͺπ¬π£π₯π₯ if you have the same problem make sure every step works. You can
1.
console.log
after the line const id = await storeUser();
on the client to check that the mutation is getting invoked,
2. console.log
inside the mutation to make sure the server is processing it
3. Check the dashboard for data and logsI get
null
unfortunatrely and I don't understand whyWhere do you get
null
? Can you share your code?However I am technically logged in even though the is doesn't show
What's
userId
on line 27?
And what do you get when you console.log
in the storeUser
mutation?I donβt get anything when I do I get null
@joe πͺπ¬π£π₯π₯ have you checked your logs on the Convex dashboard? Is your storeUser mutation getting called when you test the UI?
Also have you checked the browser developer tools? Do you get any errors there about authentication?
No its not called
hi, I can confirm that the issue was on my end. I was not calling the storeUser mutation after I changed the layout around π€¦ββοΈ
thanks for the support guys
In the frontend or backend?
@joe πͺπ¬π£π₯π₯ for me the issue was very simple, the hook that initializes the storeUser mutation wasn't even called after an user enters a page that's protected with auth.
I don't think it's a good way to store users anyway, I probably should use a callback for the clerk form, for now I'm just playing around with clerk so wanted a quick way to get started.
hooks are always called on the frontend, but I can imagine you can call convex mutations on the backend too