birving2
birving25mo ago

Using clerk node sdk in convex

I have been trying to use the "deleteUser" function offered by clerks node sdk and it doesnt seem to work. Has anyone done this before that can help point me in the right direction? (It looks like a clerk error, so if anyone can review if what im doing makes sense or needs changing, that'd be nice!) Code:
import { clerkClient } from "@clerk/clerk-sdk-node";

export const deleteUser = mutation({
args: {
id: v.id("users"),
stripeAccountId: v.string(),
clerkId: v.string(),
},
handler: async (ctx, args) => {
// Works: We are correctly integrating clerk in the auth.config.js
const userId = await ctx.auth.getUserIdentity();

// Fails: The function call fails with the error down below
const clerk = await clerkClient.users.getUser(
"user_2lk90VHBD62SUWhH1eilL3NnAI7"
);

await clerkClient.users.deleteUser(args.clerkId);
await stripe.accounts.del(args.stripeAccountId);
await ctx.db.patch(args.id, { isDeleted: true });
},
});

Error:
import { clerkClient } from "@clerk/clerk-sdk-node";

export const deleteUser = mutation({
args: {
id: v.id("users"),
stripeAccountId: v.string(),
clerkId: v.string(),
},
handler: async (ctx, args) => {
// Works: We are correctly integrating clerk in the auth.config.js
const userId = await ctx.auth.getUserIdentity();

// Fails: The function call fails with the error down below
const clerk = await clerkClient.users.getUser(
"user_2lk90VHBD62SUWhH1eilL3NnAI7"
);

await clerkClient.users.deleteUser(args.clerkId);
await stripe.accounts.del(args.stripeAccountId);
await ctx.db.patch(args.id, { isDeleted: true });
},
});

Error:
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?