Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ cron.schedule('* * * * *', async (ctx) => {
console.log(`Task started at ${ctx.triggeredAt.toISOString()}`);
console.log(`Scheduled for: ${ctx.dateLocalIso}`);

cosole.log(`Task status ${ctx.task.getStatus()}`)
console.log(`Task status ${ctx.task.getStatus()}`)
});
```

The same may be done with background tasks:

```js
// ./tasks/my-task.js
export function task() => {
export function task(ctx) {
console.log(`Task started at ${ctx.triggeredAt.toISOString()}`);
console.log(`Scheduled for: ${ctx.dateLocalIso}`);
cosole.log(`Task status ${ctx.task.getStatus()}`)
console.log(`Task status ${ctx.task.getStatus()}`)
};

```
Expand All @@ -78,4 +78,4 @@ import cron from 'node-cron';
cron.schedule('*/5 * * * * *', './tasks/my-task.js');
```

The `TaskContext` is also passed when listining task events, see more on [Event Listening Guide](https://nodecron.com/event-listening.html#taskcontext-payload)
The `TaskContext` is also passed when listining task events, see more on [Event Listening Guide](https://nodecron.com/event-listening.html#taskcontext-payload)