Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get users' own data from a collection?

How to get users' own data from a collection?

After a successful login, /auth/login does not return user-related info except the Bearer token.

So how do I request only the logged-in users' data from a collection?

While using GraphQL I can filter my result by this way if I knew my user ID. But I don't think it's the best way.

(filter:{user_created:{id:{_eq: "59d5bc57-6a67-4200-b435-553403c5b503"} }})

like image 657
Cem Kaan Avatar asked Oct 21 '25 20:10

Cem Kaan


1 Answers

It's in the docs. :)

https://docs.directus.io/reference/api/system/users/?#retrieve-the-current-user

The endpoint "${api_url}/users/me" will return the information for the currently authenticated user. You should be able to map this to GQL as you need.

like image 200
Shea Lavington Avatar answered Oct 24 '25 13:10

Shea Lavington



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!