JamalJ
Convex Community3y ago
3 replies
Jamal

Convex Argument Validtion Error?

> [CONVEX Q(projects:list)] ArgumentValidationError: Object is missing the required field `user_id`. Consider wrapping the field validator in `v.optional(...)` if this is expected.

Object: {}
Validator: v.object({user_id: v.string()})

I keep getting this error. Im not sure why?
export const list = query({
    args: {
        user_id: v.string(),
    },
    handler: async (ctx, { user_id }) => {
        const user = await getUserWithId(ctx, user_id);

        if (!user) return [];

        const projects = [];

        for (const id of user.projects) {
            const project = await ctx.db.get(id);
            if (project) {
                projects.push(project);
            }
        }

        return projects;
    },
});
Was this page helpful?