like-gold
like-gold8mo ago

is it possible to paginate the useMany hook?

I'm using the useMany hook in order to fetch relational data from multiple Airtable tables. It is really slow, is there any way to optimize this?
3 Replies
kapa.ai
kapa.ai8mo ago
Hi @jawmes.. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Hmm, I don't know enough to give you a confident answer yet. The provided extracts do not contain information about paginating the useMany hook or optimizing its performance. However, the useMany hook is used to fetch multiple records in a single request by providing the id's of the related records. This is particularly useful when you need to fetch related data for multiple records. It fetches data from a resource and returns an array of records. Here is an example of how to use the useMany hook:
import { useMany } from "@refinedev/core";

const { data } = useMany({
resource: "categories",
ids: blogPosts.map((blogPost) => blogPost.category.id),
});
import { useMany } from "@refinedev/core";

const { data } = useMany({
resource: "categories",
ids: blogPosts.map((blogPost) => blogPost.category.id),
});
In this example, the useMany hook fetches the full category records for each blog post by passing the resource and ids to the dataProvider's getMany function. The dataProvider then makes a single request to the API to fetch the full records for each category related to the blog posts. The resulting data variable is an array of category records. For more information, you can refer to the useMany documentation (https://refine.dev/docs/core/hooks/data/use-many/). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai8mo ago
<@632698368958791681> kapa.ai is still learning and improving, please let us know how it did by reacting below
correct-apricot
correct-apricot8mo ago
Hello @jawmes. I think it's a question for Airtable, not refine, as we are only responsible for sending requests.