constant-blue
constant-blue16mo ago

Getting parameters from resource

Hello. I cannot pull the myData parameter from the restfull response from the tableQueryResult. It only offers features like map, findIndex. How do I solve it?
No description
8 Replies
refine-support-bot
Hey, I am refine support bot :wave:. I am here to help you with your question. I searched for the answer to your question in the refine documentation and could not find an answer. Please wait for someone from the refine core team or the community to try to help you. 👊
harsh-harlequin
harsh-harlequin16mo ago
Hey, please repost your question in English, so our bot may help you.
constant-blue
constant-blue16mo ago
Hi. I'm unable to fetch the "myData" parameter from the data fetching from tableQueryResult. It only provides features like map, findIndex, etc. How can I solve this?
harsh-harlequin
harsh-harlequin16mo ago
I guess it's because data.data is already an array
constant-blue
constant-blue16mo ago
Yes, but the data coming from the API is structured as follows: {"message":"Success", "status":200, "myData":[]}
fair-rose
fair-rose16mo ago
Hey @Spear, useTable's first generic TData is used in the return values like TData[]. So in your case tableQueryResult?.data?.data should be the values inside myData from your API response. You can use the select function from queryOptions to transform your data to comply with useTable's expected type. https://refine.dev/docs/api-reference/core/hooks/useTable/#queryoptions
constant-blue
constant-blue16mo ago
Okey, Thanks. Can you provide an example usage? I tried but couldn't do it :/
Omer
Omer16mo ago
Hey @Spear , Could you please update your first message in English? The default language for Refine is English. Thank you for your understanding.