automatic-azure
automatic-azure14mo ago

How do I use useTable without a resource?

Hi there, I am able to use useTable to retrieve data from a mock api as long as my array of incoming objects is contained within a parent such as { assets: [{},{}...]} but the backend dev just wants to send me a plain array of objects that looks more like [{},{}...]. I tried removing the meta.resource (see attached screenshot). I also tried setting it to a blank string as well as undefined. What is the proper way to do this?
No description
4 Replies
kapa.ai
kapa.ai14mo ago
Hi @tirolawz. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
kapa.ai
kapa.ai14mo ago
---------------------- Hmm, I don't know enough to give you a confident answer yet. However, you can refer to the refine documentation for more information on how to use useTable and other related hooks: https://refine.dev/docs/api-reference/antd/hooks/table/useTable ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
useTable | refine
By using useTable, you can get properties that are compatible with Ant Design component. All features such as sorting, filtering, and pagination come out of the box. Under the hood it uses useList for the fetch.
kapa.ai
kapa.ai14mo ago
<@963837357709222000> kapa.ai is still learning and improving, please let us how it did by reacting below
fascinating-indigo
fascinating-indigo14mo ago
sorry, I couldn't fully understand the issue. but I want to point some concepts. useTable uses useList under the hood. useList calla dataProvider.getList method. you can customize or create new data provider to manipulate returning data https://refine.dev/docs/api-reference/core/providers/data-provider/#how-can-i-create-a-custom-data-provider
Data Provider | refine
Data provider acts as a data layer for your app, making HTTP requests and encapsulating how the data is retrieved. The methods of these requests are then consumed by refine via data hooks.