reactjspluginsvitestrapi

How do I access data from strapi plugin content type to admin panel content type?


I am trying to create a custom plugin in strapi.

I am kind of stuck at a place where I have a content type in plugin called Articles,

Now articles have link to users, categories and other content types in admin panel.

Now my problem is I want to access users in Plugin But I am not able to get the data in the plugin.

What is the correct method to access the data from plugin to the admin panel content types ?

I am getting 401 if i am tr=ying to access the api directly

like

/api/users
/api/categories

Can someone please help me ?


Solution

  • Maybe a little late for you, but the best way to do this is use useFetchClient

      const { get, post } = useFetchClient();   
      const test = await get('/users')
    

    this uses internal admin routes with authentication