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?
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. 👊
fascinating-indigo•2y ago
Hey, please repost your question in English, so our bot may help you.
sunny-greenOP•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?
fascinating-indigo•2y ago
I guess it's because data.data is already an array
sunny-greenOP•2y ago
Yes, but the data coming from the API is structured as follows: {"message":"Success", "status":200, "myData":[]}
sensitive-blue•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/#queryoptionssunny-greenOP•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.