sensitive-blue
sensitive-blue10mo ago

I am using @refinedev/core useList

export const ProfileList: React.FC = () => {
const { data } = useList<IProfile, HttpError, IProfile>({
resource: `profiles`,
meta: {
fields: ["id", "firstName", "lastName"],
populate: "*",
},
});

const profiles= data?.data ?? [];
console.log('profiles: ', profiles)
export const ProfileList: React.FC = () => {
const { data } = useList<IProfile, HttpError, IProfile>({
resource: `profiles`,
meta: {
fields: ["id", "firstName", "lastName"],
populate: "*",
},
});

const profiles= data?.data ?? [];
console.log('profiles: ', profiles)
Strapi V4 is my dataprovider My console.log is returning 10 items when my backend shows 12 items. I can't find anything wrong with my query it should be populating all 12 items. What am I doing wrong? If I go to my edit page and chane the url to the ID of 1 of the missing items it will load it no issues. but in my list page it just does not load more than 10 items. If i change the pagnation to 5, it still loads 10 items but lets me tab between the 2 pages of results. I confirmed in strapi my api rest defaultLimit is 25. I have a query for a select in the create page that pulls the same stuff and it loads all my items so it has to be something with the list I just can't find it.
2 Replies
kapa.ai
kapa.ai10mo ago
Hi @erekyu. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in the extracts, it seems like you might be encountering an issue with the default pagination settings of the useList hook in refine. In refine, the default page size for the useList hook is 10, which might explain why you're only seeing 10 items even though there are more items in your backend. To fetch more items, you can specify a pagination option in the useList hook with a larger pageSize. Here's an example:
const { data } = useList<IProfile, HttpError, IProfile>({
resource: `profiles`,
pagination: {
pageSize: 25, // Fetch 25 items per page
},
meta: {
fields: ["id", "firstName", "lastName"],
populate: "*",
},
});
const { data } = useList<IProfile, HttpError, IProfile>({
resource: `profiles`,
pagination: {
pageSize: 25, // Fetch 25 items per page
},
meta: {
fields: ["id", "firstName", "lastName"],
populate: "*",
},
});
This will fetch 25 items per page, which should cover all your items since your Strapi's defaultLimit is also set to 25. If you're still encountering issues, it might be helpful to check the network requests in your browser's developer tools to see if the correct requests are being sent to your backend. For more information on how to use the useList hook in refine, you can refer to the refine documentation (https://refine.dev/docs/api-reference/hooks/data/useList/). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai10mo ago
<@66380739771379712> kapa.ai is still learning and improving, please let us know how it did by reacting below