filter on useList
Hello,
I am trying to apply filters on useList data query from API but looks like filter is not working.
I want the list of users with "admin" role.
interface User {
_id: string;
name: string;
role: string;
}
const { data: Admin } = useList<User>({
resource: "users",
config: {
hasPagination: false,
filters: [
{
field: "role",
operator: "eq",
value: "admin",
},
],
},
});
const admin: User[] = Admin?.data ?? [];
console.log("admin:", admin);
and the result as the screenshot
hasPagination and pagination are working fine but filters and sort are not.
I checked the documentation but still not sure what is wrong with my code.
https://refine.dev/docs/api-reference/core/hooks/data/useList/
Thank you in advance.
I am trying to apply filters on useList data query from API but looks like filter is not working.
I want the list of users with "admin" role.
interface User {
_id: string;
name: string;
role: string;
}
const { data: Admin } = useList<User>({
resource: "users",
config: {
hasPagination: false,
filters: [
{
field: "role",
operator: "eq",
value: "admin",
},
],
},
});
const admin: User[] = Admin?.data ?? [];
console.log("admin:", admin);
and the result as the screenshot
hasPagination and pagination are working fine but filters and sort are not.
I checked the documentation but still not sure what is wrong with my code.
https://refine.dev/docs/api-reference/core/hooks/data/useList/
Thank you in advance.

useList is an extended version of TanStack Query's useQuery. It supports all the features of useQuery and adds some extra features.

