rare-sapphire
rare-sapphire•2y 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
refine-support-bot•2y ago
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. 👊
adverse-sapphire
adverse-sapphire•2y ago
Hey, please repost your question in English, so our bot may help you.
rare-sapphire
rare-sapphire•2y 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?
adverse-sapphire
adverse-sapphire•2y ago
I guess it's because data.data is already an array
rare-sapphire
rare-sapphire•2y ago
Yes, but the data coming from the API is structured as follows: {"message":"Success", "status":200, "myData":[]}
foreign-sapphire
foreign-sapphire•2y 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
rare-sapphire
rare-sapphire•2y ago
Okey, Thanks. Can you provide an example usage? I tried but couldn't do it :/
Omer
Omer•2y ago
Hey @Spear , Could you please update your first message in English? The default language for Refine is English. Thank you for your understanding.