Bug in docs

I would argue for removing the + 1 in ${events.length + 1} in your getting started code.
import { workflow } from '@novu/framework';
const commentWorkflow = workflow('comment-on-post', async (event) => {
const inAppResponse = await event.step.inApp('notify-user', async () => ({
body: renderReactComponent(event.payload.postId)
}));
const { events } = await event.step.digest('1 week');
await event.step.email('weekly-comments', async (inputs) => {
return {
subject: `Weekly post comments (${events.length + 1})`,
body: renderReactEmail(inputs, events)
};
}, { skip: () => inAppResponse.seen });
}, { payloadSchema: z.object({ postId: z.string() }) }
);
// Use the same familiar syntax to send a notification
commentWorkflow.trigger({
to: { subscriberId: '[email protected]' },
payload: { postId: '12345' }
});
import { workflow } from '@novu/framework';
const commentWorkflow = workflow('comment-on-post', async (event) => {
const inAppResponse = await event.step.inApp('notify-user', async () => ({
body: renderReactComponent(event.payload.postId)
}));
const { events } = await event.step.digest('1 week');
await event.step.email('weekly-comments', async (inputs) => {
return {
subject: `Weekly post comments (${events.length + 1})`,
body: renderReactEmail(inputs, events)
};
}, { skip: () => inAppResponse.seen });
}, { payloadSchema: z.object({ postId: z.string() }) }
);
// Use the same familiar syntax to send a notification
commentWorkflow.trigger({
to: { subscriberId: '[email protected]' },
payload: { postId: '12345' }
});
3 Replies
Novu_Bot
Novu_Bot4d ago
@christian, you just advanced to level 1!
Pawan Jain
Pawan Jain4d ago
@christian Thanks for sharing. I agree with events.length, + 1 is not required
Tomer Barnea
Tomer Barnea3d ago
Thanks @christian, much appriciated!
Want results from more Discord servers?
Add your server