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](https://cdn.answeroverflow.com/1081098084186071101/Ekran_Resmi_2023-03-03_09.10.21.png)
8 Replies
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•2y ago
Hey, please repost your question in English, so our bot may help you.
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•2y ago
I guess it's because data.data is already an array
rare-sapphire•2y ago
Yes, but the data coming from the API is structured as follows: {"message":"Success", "status":200, "myData":[]}
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/#queryoptionsrare-sapphire•2y ago
Okey, Thanks. Can you provide an example usage? I tried but couldn't do it :/
Hey @Spear ,
Could you please update your first message in English? The default language for Refine is English. Thank you for your understanding.