useCustom get request not sending meta populate params (Strapi)
Hi, i'm trying to make a request to get a resource with a relation populated trough the useCustom hook to make the request.
But when the browser sends the request, there are no populate fields param settedf in the request.
I'm using Strapi dataProvider backend.
This is the
useCustom
call
this is the request that the browser sends to the API:
- url: GET http://localhost:1337/api/slots/69?
- response:
6 Replies
Hi @kraloz. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the information provided in the extracts, it seems like you're trying to populate the
jobRole
field in your slots
resource using the useCustom
hook. However, the useCustom
hook does not support the meta
property for populating fields.
Instead, you can use the useTable
or useList
hooks to populate fields in your resources. These hooks support the meta
property, which you can use to specify the fields you want to populate.
Here's an example of how you can use the useTable
hook to populate the jobRole
field in your slots
resource:
And here's an example of how you can use the useList
hook:
This will send a request to /slots?populate=jobRole
.
For more information, you can refer to the Refine documentation (https://refine.dev/docs).
Sources:
- Refine Documentation (https://refine.dev/docs/packages/documentation/data-providers/strapi-v4/)
- Refine Blog (https://refine.dev/blog/react-admin-panel/)
- Discord Support Thread (https://discord.com/channels/837692625737613362/1160933198507823227)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@240270957686554624> kapa.ai is still learning and improving, please let us know how it did by reacting below
other-emerald•11mo ago
The useCustom hook docs shows the meta option support: https://refine.dev/docs/api-reference/core/hooks/data/useCustom/#meta
useCustom | refine
useCustom is used to send custom query requests using the Tanstack Query advantages. It is an extended version of TanStack Query's useQuery and not only supports all features of the mutation but also adds some extra features.
other-emerald•11mo ago
I found that the useOne hook is much better situable for this use case
other-emerald•11mo ago
useOne | refine
useOne is an extended version of TanStack Query's useQuery that supports all of its features and adds some more.
other-emerald•11mo ago
but the question is still unresolved