Strapi get relational data

277 Views Asked by At

I am new to Strapi and building an application were an authicated user should be able to save bookmarks. On the dashboard for the logged in user it should display a list of the user's bookmarks. However, I seem to be unable to get the relations user has many bookmarks. I have tried several ways, for instance creating a custom controller with the following:

const data = await strapi.services.bookmarks.find({ Users_premissions_user: { id: 1 } });

I have also tried with /users/me, but that only returns basic information about the user (no relational data). Basically, what I want to achieve is something similar to SELECT * FROM bookmarks WHERE user_id = 1.

Any help or pointers is appreciated.

1

There are 1 best solutions below

0
Ayodeji On

You'll need to deeply populate the response. You can add a populate query to the API call

http://localhost:1337/api/[collection/single type]?populate=*

or..

if you're on StrapiV4 you can check out this populate deep plugin