#Bug in docs

1 messages · Page 1 of 1 (latest)

gritty tapir
#

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' }
});
thin ridgeBOT
#

@gritty tapir, you just advanced to level 1!

unique trench
#

@gritty tapir

Thanks for sharing. I agree with events.length, + 1 is not required

spice nexus
#

Thanks @gritty tapir, much appriciated!

gritty tapir
#

Noticed it because I use almost exactly this example in my application. Such an easy way of performing what could be a complex task. Thank you for this product