79237256

Date: 2024-11-29 13:32:47
Score: 0.5
Natty:
Report link

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>
  );
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Soumi Ghosh