You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have not already reached out to Clerk support via email or Discord (if you have, no need to open an issue here)
This issue is not a question, general help request, or anything other than a bug report directly related to Clerk. Please ask questions in our Discord community: https://clerk.com/discord.
LuccaRebelloToledo
changed the title
Bug Report: Error When Parsing UserJSON to User
[@clerk/backend] Bug Report: Error When Parsing UserJSON to User
Feb 7, 2025
LuccaRebelloToledo
changed the title
[@clerk/backend] Bug Report: Error When Parsing UserJSON to User
[@clerk/express] Bug Report: Error When Parsing UserJSON to User
Feb 7, 2025
Hi @LuccaRebelloToledo, after reviewing the code I don't think the User type is meant to be used that way. It is probably provided for internal use. Is there a reason why you can't use the userEvent variable directly? but if you absolutely want to deal with user types what if you do it this way:
import{clerkClient}from"@clerk/express";app.post("/webhook",async(req,res)=>{try{constuserEvent=req.body;console.log("User Event:",userEvent);constuserId=userEvent.id;constuser=awaitclerkClient.users.getUser(userId);console.log("Fetched User:",user);res.status(200).send("Webhook received");}catch(error){console.error("Error processing webhook:",error);res.status(500).send("Internal server error");}});
Hey @Nelwhix, how are you? In the project I'm working on, I use many methods that take the User type as a parameter. It would be unfeasible for me to convert all the methods to use UserJSON. Also, if there was an update, I would have to update twice :/
Therefore, converting JSON to the User class ends up being quite important to me and will minimize requests in Clerk, consequently reducing costs.
Preliminary Checks
I have reviewed the documentation: https://clerk.com/docs
I have searched for existing issues: https://github.com/clerk/javascript/issues
I have not already reached out to Clerk support via email or Discord (if you have, no need to open an issue here)
This issue is not a question, general help request, or anything other than a bug report directly related to Clerk. Please ask questions in our Discord community: https://clerk.com/discord.
Reproduction
Zip
Publishable key
pk_test_c2V0LXR1bmEtNzUuY2xlcmsuYWNjb3VudHMuZGV2JA
Description
Steps to reproduce:
Expected behavior:
The UserJSON should successfully convert into a User object.
Actual behavior:
An error occurs:
clerk-use-case.zip
Environment
The text was updated successfully, but these errors were encountered: