Skip to content

Commit

Permalink
docs: async example
Browse files Browse the repository at this point in the history
  • Loading branch information
hywax committed Mar 22, 2024
1 parent 215100f commit 403e8f7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default defineConfig({
{ text: 'Base', link: '/base' },
{ text: 'Run on init', link: '/with-params' },
{ text: 'Custom time', link: '/custom-time' },
{ text: 'Async', link: '/async' },
],
},
{
Expand Down
16 changes: 16 additions & 0 deletions docs/examples/async.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Async

`defineCronHandler` supports async functions.

```ts
// server/cron/job.ts
import { defineCronHandler } from '#nuxt/cron'

export default defineCronHandler('houdrly', async () => {
const data = $fetch('https://jsonplaceholder.typicode.com/todos/1')

console.log(data)
})
```

A list of all prepared times can be found in [Presets](../api/presets)

0 comments on commit 403e8f7

Please # to comment.