Incorrect Destructuring of Event Data in Webhooks Integration Example
rupaut98 opened this issue · 0 comments
rupaut98 commented
In the webhooks integration example on the Clerk documentation site, there is an error in the code snippet for the sendWelcomeEmail function. The code currently uses incorrect destructuring of the event.data object, which results in an error.
The current code snippet is:
const sendWelcomeEmail = inngest.createFunction(
{ id: 'send-welcome-email' },
{ event: 'clerk/user.created' },
async ({ event }) => {
const { user } = event.data;
const { first_name } = user;
const email = user.email_addresses.find(e =>
e.id === user.primary_email_address_id
).email_address;
// `emails` is a placeholder for the function in your codebase to send email
await emails.sendWelcomeEmail({ email, first_name });
}
);
The corrected code should be:
{ id: 'send-welcome-email' },
{ event: 'clerk/user.created' },
async ({ event }) => {
const user = event.data;
const { first_name } = user;
const email = user.email_addresses.find(e =>
e.id === user.primary_email_address_id
).email_address;
// `emails` is a placeholder for the function in your codebase to send email
await emails.sendWelcomeEmail({ email, first_name });
}
);
This change ensures that the user object is correctly assigned from event.data. Please update the documentation to reflect this correction.