M ZeeshanM
Convex Community17mo ago
57 replies
M Zeeshan

Authentication in paginated query

How do I implement user authentication checks in paginated queries

error:
Type '{ success: boolean; message: string; }' is missing the following properties from type 'PaginationResult<any>': page, isDone, continueCursor


server:
query({
  handler: async () => {
    const user = await ctx.auth.getUserIdentity();

    if (!user) {
      return {
        success: false,
        message: 'unauthenticated request',
      };
    }

    return await queryBuilder
      .order('desc')
      .paginate(args.paginationOpts);
  },
});

front-end:
  const { results, loadMore, status, isLoading } = usePaginatedQuery(
    api.hire_requests.getMultiple,  // <---- EROR HERE
    args,
    { initialNumItems: 20 },
  );
Was this page helpful?