I have finally found the solution. I have changed axios.get(
http://localhost:1000/users?_page=${pageParam}&_limit=2);
this to : axios.get(http://localhost:1000/users?_page=${pageParam}&_per_page=2
);
The response is a little complex, I have used map within a map to display data, But it is working fine.
The return part is :
return (
<div>
{
data?.pages?.map((page,index)=>(
<React.Fragment key={index}>
{
page.data.data.map((usr) => (
<div key={usr.id}>
<h2>{usr.name}</h2>
<hr />
</div>
))
}
</React.Fragment>
))
}
<div>
<button disabled={!hasNextPage} onClick={fetchNextPage}>
Load more
</button>
</div>
<div>{isFetching && !isFetchingNextPage ? "Fetching..." : null}</div>
</div>
);